Problem uploading file through a form with Internet Explorer
Hi, I have a problem uploading files through a form with Internet Explorer (Opera, Mozilla work fine). I am doing following stuff: I've got a webpage with something like: <form action="uploadPhoto" method="post" enctype="multipart/form-data"> <input type="file" name="file" maxlength="1000000" accept="image/*"> <input value="submit"> </form> uploadPhoto is a DTML document which has following code to process the uploaded data: <dtml-if "_.getattr(file,'filename') != ''"> <dtml-call expr="aq_parent.manage_addProduct['Photo'].manage_addPhoto(_.getattr(file,'filename'),'A photo',file,store='ExtImage',pregen=1)"> </dtml-if> It works perfectly as long as I use Mozilla (both under Linux and Windows) or Opera (tested only under Windows), but as soon as I try to use Internet Explorer Zope returns an error message saying that there are characters not allowed in URLs. Uploading photos from the management interface works perfectly. I would be greatful if anyone could suggest a solution for this problem or explain it to me. It's a big mistery to me. Thanks, Stephan -- Stephan Witoszynskyj <swito@fsmat.htu.tuwien.ac.at>
Swito wrote:
It works perfectly as long as I use Mozilla (both under Linux and Windows) or Opera (tested only under Windows), but as soon as I try to use Internet Explorer Zope returns an error message saying that there are characters not allowed in URLs. Uploading photos from the management interface works perfectly.
I would be greatful if anyone could suggest a solution for this problem or explain it to me. It's a big mistery to me.
It's easy. The client/webbrowser sets the filename. Mozilla, among others, removes the path part of the filename. IE sets it to the full path. Given a file at this location: c:/image/logo.jpg IE: c:/image/logo.jpg Mozilla: logo.jpg So to make shure that you only get the filename part of the path, you need to parse the path, and remove the extra fluff. Or use the addPhoto() method in the Photo product. Which seems to do the right thing. Eg call "id, title = OFS.Image.cookId(id, title, file)" regards Max M
participants (2)
-
Max M -
Swito