On Thu, Nov 5, 2009 at 6:53 PM, Margie Roginski <margierogin...@yahoo.com>wrote:
> > In my app, my user inputs one more more attachments and on the server > side I am successfully getting them via code like this: > > for file in request.FILES.getlist('attachment'): > a = Attachment( > filename = filename, > mime_type=mimetypes.guess_type(filename)[0] or > 'application/octet-stream', > size=file.size, > ) > > In certain cases the user has errors in other parts of the form, and I > need to re-render the form. In this case I would like to re-fill the > inputs that they originally filled with the paths to their > attachments. IE, prior to submitting the form, they browsed to some > file and selected it as their attachment. When I re-render the form > after detecting an error, I would like them to not have to re-browse > to find their attachment again. > > However, I do not see any way of getting the orignal path name from > the InMemoryUploadedFile that I have access to in my <file> variable. > > Does anyone know if there is a way to get this original path? > > It doesn't matter if you are able to retrieve the original file location, the browser won't use it. Allowing the server to pre-fill a FileInput field is considered to dangerous -- if browsers allowed this then users could be unwittingly tricked into uploading sensitive files by malicious servers. Browsers require the user to manually select a file each time one is uploaded. Karen --~--~---------~--~----~------------~-------~--~----~ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---