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.


function downloadFile(filename){

<table id='filetable' border = '1'>
{% for i in q  %}
   <a href='C:\Users\rdoshi\storage\{{i.file_name}}'>{{i.file_name}}</a>
   <button type="button" 
 {% endfor %}
<form method = "post" action="../upload/" enctype ="multipart/form-data">{% 
csrf_token %}
         <input type="file" name="files" multiple />
<input type = "submit" value="Upload" />


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)
for chunk in f.chunks():
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 django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
For more options, visit https://groups.google.com/d/optout.

Reply via email to