Hi everybody, the following script running on the dev server with Py2.4/Win2k3 (tested on both IE7 and FF2) crashes the dev server. The funny thing is that the files get actually written to the filesystem and CPU usage is normal.
What i'm trying to do is allow uploading of an undeterminate number N of files, just as GMail does. The javascript part uses jquery. Thanks, Lorenzo ########template################### {%extends "base_template.html"%} {%block content%} <script type="text/javascript"> function addImageField() { var rndName = Math.ceil(Math.abs(Math.random() * 100000)); var chunk = "Description <input type='text' name='des" + rndName + "' /> <input type='file' name='img" + rndName + "' /><br />"; $("#imagefields").append(chunk); } </script> {%if error_msg%} <span class="error">{{error_msg}}</span> {%endif%} {%if info_msg%} <span class="info">{{info_msg}}</span> {%endif%} {{form.errors.as_ul}} <form action="" method="post" enctype="multipart/form-data"> Description {{form.description}} {{form.myfile}} <br /> <div id="imagefields"> </div> <br /> <a href="#" onclick="addImageField();">Attach another file</a> <br /> <input type="submit" value="go"> </form> {%endblock%} ################view############### class FileUploadForm(Form): description = CharField(required=False) myfile = CharField(widget=FileInput(), required=False) def file_upload(request): if request.method == "POST": new_data = request.POST.copy() new_data.update(request.FILES) form = FileUploadForm(new_data) if form.is_valid(): for k in request.FILES.keys(): print "%s %s %s %s" % (k, new_data[k]["filename"], new_data[k]["content-type"], new_data[k]["content"]) f = file("C:\\temp\\%s" % k, "wb") try: f.write(new_data[k]["content"]) f.close() except: pass return HttpResponse("Success") else: context = dict(form=form, error_msg="Upload went bananas!") else: form = FileUploadForm() context = dict(form=form) return render_to_response("fileupload.html", context) --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com 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 -~----------~----~----~----~------~----~------~--~---