0

I am using ng-file-upload library to post files to my back end Web Api. Once the file is posted I save it to the following folder

"~/App_Data/Tmp/FileUploads/"

and also save the path to my database.

Now when I go on edit mode; I want to get a preview of all uploaded files (photos). But when I use something like

ng-src="path"

I get

"Not allowed to load local resource"

is this the right approach, when serving files from disk?

Medet Tleukabiluly
  • 11,662
  • 3
  • 34
  • 69
den
  • 709
  • 2
  • 7
  • 19

1 Answers1

0

That path is a server path and not a client path so for sure that won't work.

You need to have an endpoint on your server to allow downloading those files with id or name/path and then set the src of the img to that url.

The implementation download endpoint depends on your backend technology.

If in your edit mode you still have access to the file object that use has just selected then you can do:

<img ngf-src="file">
danial
  • 4,058
  • 2
  • 32
  • 39
  • how can i create an endpoint in ASP.NET Web API to respond to http://localhost:37020/App_Data/Tmp/FileUploads/248/tag2.png – den Aug 30 '15 at 19:38
  • http://stackoverflow.com/questions/8897458/asp-net-download-file-to-client-browser – danial Aug 30 '15 at 23:12
  • thanks, but how i enable this webpoint. I tried to create a new route ; but that doesnt seem to work – den Aug 31 '15 at 09:18
  • This seems like a separate issue, open an new one or search for "How to download files form server in .Net" – danial Aug 31 '15 at 22:01