On Wed, Aug 17, 2011 at 8:39 PM, Daniel Roseman <[email protected]> wrote: > On Wednesday, 17 August 2011 19:00:13 UTC+1, Adam Zedan wrote: >> >> Hi it seems I cant access data from local static paths such as >> c:\\somefolder\somefile.gif in my templates when I enter the url >> the code for my template is simplified to something like this >> >> <!DOCTYPE HTML> >> <html> >> <head> >> <meta http-equiv="Content-Type" content="text/html; >> charset=iso-8859-1"> >> <title>Demo</title> >> </head> >> <body> >> <img src="file:///c:/bender.gif" /> >> </body> >> </html> >> >> The title change to Demo. which shows that the page has loaded but >> I get the error in firefox saying: >> Security Error: Content at http://127.0.0.1:8000/db/ may not load or link >> to file:///c://bender.gif > > > No, you can't do that. Why would you want to? Your users aren't going to > have that file on their machines, so what's the point of referencing a local > file path? > You serve the content through your webserver, with an http:// protocol. In > development, you can do this through Django's development server: > https://docs.djangoproject.com/en/1.3/howto/static-files/ > -- > DR. >
The OP clearly doesn't understand why though, see his other thread on this topic. Your browser is a careful beast. It won't allow a webpage loaded from the internet zone to load things from the local zone, as That Would Be Bad. When you 'double click' the file and 'it works', what is actually happening is that the webpage is loaded from the local zone, and so access is allowed. Also, Django is a web app. This means that most users who use your site will not be using it from your desktop, so they would not be able to access files on your local machine. Therefore, you need to provide a way to serve these files over HTTP, so that other users can access them. See the link in Daniel's reply on how to do this. Cheers Tom -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

