[OffTopic]Browser Specific Issue
Hi Everyone, This is not a Zope related question but I am posting it here since it is likely that some of you may have encountered it and solved it. So my apologies. I am working on a form where user is expected to browse the homes for a file and select the one he desires to be processed. I am using following statement to display the necessary control. <input type="File" name="file_name"> On IE when I use file_name I get complete path of the file which is exactly what I desire.but on GNU/Linux based Web Browsers like mozilla, galeon etc. only name of the file is returned. How can I get the complete path even on these browsers. The form is written entirely in dtml. I ve looked for answers via Google but I hv not had much luck so far. It is obvious from the question that I am lame at HTML. But please help/pointers anybody. Thanks in Advance Shashank
Shashank Ashtikar wrote:
Hi Everyone,
This is not a Zope related question but I am posting it here since it is likely that some of you may have encountered it and solved it.
So my apologies.
I am working on a form where user is expected to browse the homes for a file and select the one he desires to be processed. I am using following statement to display the necessary control.
<input type="File" name="file_name">
On IE when I use file_name I get complete path of the file which is exactly what I desire.
Uhm, okay, but as Terry wrote, file_name shouldn't give you the filename in any case. Have you used the right enctype attribute in your form tag? If you haven't used one, this is an error. You can find out how to upload files by looking at the html source of e.g. zope's file manangement screen. About the full path, there I can't help you. cheers, oliver
apart from the issue whether file_name returns a string containing path or name or a real file upload (which it should, if it does not your form is buggy), IE mis-behaves (oh wonder) in revealing full paths instead of just the file name. if the form is done right you will get a HTTPFileUpload instance which behaves like a python file. it has an attribute "filename" that contains the name of the file. in IE, you get the full path, which is wrong for most applications. in all other browsers you get just the file name. jens On Wednesday, Jun 4, 2003, at 04:42 US/Eastern, Shashank Ashtikar wrote:
Hi Everyone,
This is not a Zope related question but I am posting it here since it is likely that some of you may have encountered it and solved it.
So my apologies.
I am working on a form where user is expected to browse the homes for a file and select the one he desires to be processed. I am using following statement to display the necessary control.
<input type="File" name="file_name">
On IE when I use file_name I get complete path of the file which is exactly what I desire.but on GNU/Linux based Web Browsers like mozilla, galeon etc. only name of the file is returned. How can I get the complete path even on these browsers.
The form is written entirely in dtml.
I ve looked for answers via Google but I hv not had much luck so far. It is obvious from the question that I am lame at HTML. But please help/pointers anybody.
Thanks in Advance
Shashank
On Wed, Jun 04, 2003 at 08:00:37AM -0400, Jens Vagelpohl wrote: Hi,
apart from the issue whether file_name returns a string containing path or name or a real file upload (which it should, if it does not your form is buggy), IE mis-behaves (oh wonder) in revealing full paths instead of just the file name.
Thought so it would be the case.
if the form is done right you will get a HTTPFileUpload instance which behaves like a python file. it has an attribute "filename" that contains the name of the file. in IE, you get the full path, which is wrong for most applications. in all other browsers you get just the file name.
All that you are saying is new to me. I ve never worked on forms for uplodaing the data. It seems the person who wrote the form originally also did not understand these issues. Thats why the application expects the entire path instead of a file. So now I will need to rewrite the product a bit. Like instead of processing file directly on the filesystem I should get it inside ZMI and process it there. The application uses an External method for processing the file. So this should not be a problem. Any suggestions are welcome. Thanks to all of you. Shashank
All that you are saying is new to me. I ve never worked on forms for uplodaing the data. It seems the person who wrote the form originally also did not understand these issues. Thats why the application expects the entire path instead of a file.
So now I will need to rewrite the product a bit. Like instead of processing file directly on the filesystem I should get it inside ZMI and process it there. The application uses an External method for processing the file. So this should not be a problem.
Any suggestions are welcome.
make sure the form tag has an enctype attribute that look like this: enctype="multipart/form-data" otherwise you will never get the file data uploaded and will always just get the file name (or path in IE). jens
At 09:42 04/06/2003, Shashank Ashtikar wrote:
Hi Everyone,
This is not a Zope related question but I am posting it here since it is likely that some of you may have encountered it and solved it.
So my apologies.
I am working on a form where user is expected to browse the homes for a file and select the one he desires to be processed. I am using following statement to display the necessary control.
<input type="File" name="file_name">
On IE when I use file_name I get complete path of the file which is exactly what I desire.but on GNU/Linux based Web Browsers like mozilla, galeon etc. only name of the file is returned. How can I get the complete path even on these browsers.
Non-MS browser on Windows, such as Netscape 7 and Opera do not supply the complete path. IE seems to alone in exhibiting this behaviour, which is questionable from a security standpoint.
The form is written entirely in dtml.
I ve looked for answers via Google but I hv not had much luck so far. It is obvious from the question that I am lame at HTML. But please help/pointers anybody.
According to the relevant RFC, supplying the filename is not mandatory and certainly the full file path is not required. I do not know why you want the full path as this is, broadly speaking, irrelevant to the server as, presumably, it does not have access to the filespace on the client uploading the file. Certainly the client is not required to supply the full path. <quote document="RFC1867" section="3.3 use of multipart/form-data"> The original local file name may be supplied as well, either as a 'filename' parameter either of the 'content-disposition: form-data' header or in the case of multiple files in a 'content-disposition: file' header of the subpart. The client application should make best effort to supply the file name; if the file name of the client's operating system is not in US-ASCII, the file name might be approximated or encoded using the method of RFC 1522. This is a convenience for those cases where, for example, the uploaded files might contain references to each other, e.g., a TeX file and its .sty auxiliary style description. </quote>
Thanks in Advance
Shashank
_______________________________________________ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
On Wednesday 04 June 2003 01:42 am, Shashank Ashtikar wrote:
I am working on a form where user is expected to browse the homes for a file and select the one he desires to be processed. I am using following statement to display the necessary control.
<input type="File" name="file_name">
On IE when I use file_name I get complete path of the file which is exactly what I desire.but on GNU/Linux based Web Browsers like mozilla, galeon etc. only name of the file is returned. How can I get the complete path even on these browsers.
That doesn't make sense to me -- a "file" input should return (POST) the *contents* of the file, not the file name, right? Anyway, giving the full pathname on the client machine is possibly a security violation, isn't it? (i.e. the server shouldn't be able to introspect the client's filesystem). Or am I misunderstanding your question? Cheers, Terry -- Terry Hancock ( hancock at anansispaceworks.com ) Anansi Spaceworks http://www.anansispaceworks.com
participants (5)
-
Jens Vagelpohl -
Oliver Bleutgen -
Richard Barrett -
Shashank Ashtikar -
Terry Hancock