Hi ,I want to setup a dropbox like server with django. So far i have achieved uploading files onto a location .I want these files to show up on browser which they do(while saving file to the location I indexed an entry in the Db so i just print the file names from the DB(POSTGRESQL).Now i want to provide users options to view or download the files.I put a link on it and tried ,it did not work since it shows an javascript error "NOT ALLOWED TO LOAD LOCAL RECOURCE" . All uploaded files are loaded in C drive of my laptop. Where else do i load so that javascript can load it? Attaching my code ..thanks in advance.
Index.html <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script> <script> function downloadFile(filename){ } </script> <table id='filetable' border = '1'> {% for i in q %} <tr> <td>{{i.id}}</td> <td> <a href='C:\Users\rdoshi\storage\{{i.file_name}}'>{{i.file_name}}</a> <button type="button" onclick="downloadFile("{{i.file_name}}")">Download</button> </td> </tr> {% endfor %} </table> <form method = "post" action="../upload/" enctype ="multipart/form-data">{% csrf_token %} <input type="file" name="files" multiple /> <input type = "submit" value="Upload" /> </form> views.py from django.shortcuts import render from django.http import HttpResponse from django.shortcuts import render_to_response from polls.models import Files from os import walk from os.path import isfile, join def index(request): return render(request,"index.html", {}) def upload(request): for x in request.FILES.getlist("files"): def process(f): with open(r'C:\Users\rdoshi\storage\%s ' %f.name , 'wb+') as destination: b = Files(file_name= f.name) b.save() for chunk in f.chunks(): destination.write(chunk) process(x) q = Files.objects.all() return render(request, "index.html", {'q' : q}) -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/b6396853-ae8f-4fef-ac91-7ab235eb22b0%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.

