get full pathname file from form
Hi all, I want to upload a file with this form. <FORM ACTION="upload_file" METHOD="POST" ENCTYPE="multipart/form-data"> <INPUT TYPE="FILE" NAME="FILE" > <INPUT TYPE="SUBMIT" VALUE="Upload" NAME="ACTION" > </FORM> To check the size with os.path.getsize(file) I need the filename with the whole path. How can I get this from the form variables ? Regards. Michael
call len() on the body of the received data. Except MSIE ,you will you receive the filename and not the complete path. -aj --On Dienstag, 19. August 2003 16:44 Uhr +0200 Michael Bleijerveld <michael@bleijerveld.nl> wrote:
Hi all,
I want to upload a file with this form.
<FORM ACTION="upload_file" METHOD="POST" ENCTYPE="multipart/form-data">
<INPUT TYPE="FILE" NAME="FILE" > <INPUT TYPE="SUBMIT" VALUE="Upload" NAME="ACTION" >
</FORM>
To check the size with os.path.getsize(file) I need the filename with the whole path.
How can I get this from the form variables ?
Regards.
Michael
_______________________________________________ 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 )
Hi Andreas, This doesn't work for me. When I want to get the filesize of a large file (10 MB or more) I takes a long time to get the result. Therefore I want to use os.path.getsize. Michael ----- Original Message ----- From: "Andreas Jung" <andreas@andreas-jung.com> To: "Michael Bleijerveld" <michael@bleijerveld.nl>; <zope@zope.org> Sent: Tuesday, August 19, 2003 4:51 PM Subject: Re: [Zope] get full pathname file from form
call len() on the body of the received data. Except MSIE ,you will you receive the filename and not the complete path.
-aj
--On Dienstag, 19. August 2003 16:44 Uhr +0200 Michael Bleijerveld <michael@bleijerveld.nl> wrote:
Hi all,
I want to upload a file with this form.
<FORM ACTION="upload_file" METHOD="POST" ENCTYPE="multipart/form-data">
<INPUT TYPE="FILE" NAME="FILE" > <INPUT TYPE="SUBMIT" VALUE="Upload" NAME="ACTION" >
</FORM>
To check the size with os.path.getsize(file) I need the filename with the whole path.
How can I get this from the form variables ?
Regards.
Michael
_______________________________________________ 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 )
len() on a string of 10MB should be done in less than a second. -aj --On Dienstag, 19. August 2003 17:01 Uhr +0200 Michael Bleijerveld <michael@bleijerveld.nl> wrote:
Hi Andreas,
This doesn't work for me. When I want to get the filesize of a large file (10 MB or more) I takes a long time to get the result. Therefore I want to use os.path.getsize.
Michael
----- Original Message ----- From: "Andreas Jung" <andreas@andreas-jung.com> To: "Michael Bleijerveld" <michael@bleijerveld.nl>; <zope@zope.org> Sent: Tuesday, August 19, 2003 4:51 PM Subject: Re: [Zope] get full pathname file from form
call len() on the body of the received data. Except MSIE ,you will you receive the filename and not the complete path.
-aj
--On Dienstag, 19. August 2003 16:44 Uhr +0200 Michael Bleijerveld <michael@bleijerveld.nl> wrote:
Hi all,
I want to upload a file with this form.
<FORM ACTION="upload_file" METHOD="POST" ENCTYPE="multipart/form-data">
<INPUT TYPE="FILE" NAME="FILE" > <INPUT TYPE="SUBMIT" VALUE="Upload" NAME="ACTION" >
</FORM>
To check the size with os.path.getsize(file) I need the filename with the whole path.
How can I get this from the form variables ?
Regards.
Michael
_______________________________________________ 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 )
_______________________________________________ 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 )
It's takes more than 40 seconds to check a filesize of a 10 MB file. ----- Original Message ----- From: "Andreas Jung" <andreas@andreas-jung.com> To: "Michael Bleijerveld" <michael@bleijerveld.nl>; <zope@zope.org> Sent: Tuesday, August 19, 2003 5:05 PM Subject: Re: [Zope] get full pathname file from form
len() on a string of 10MB should be done in less than a second.
-aj
--On Dienstag, 19. August 2003 17:01 Uhr +0200 Michael Bleijerveld <michael@bleijerveld.nl> wrote:
Hi Andreas,
This doesn't work for me. When I want to get the filesize of a large file (10 MB or more) I takes a long time to get the result. Therefore I want to use os.path.getsize.
Michael
----- Original Message ----- From: "Andreas Jung" <andreas@andreas-jung.com> To: "Michael Bleijerveld" <michael@bleijerveld.nl>; <zope@zope.org> Sent: Tuesday, August 19, 2003 4:51 PM Subject: Re: [Zope] get full pathname file from form
call len() on the body of the received data. Except MSIE ,you will you receive the filename and not the complete path.
-aj
--On Dienstag, 19. August 2003 16:44 Uhr +0200 Michael Bleijerveld <michael@bleijerveld.nl> wrote:
Hi all,
I want to upload a file with this form.
<FORM ACTION="upload_file" METHOD="POST" ENCTYPE="multipart/form-data">
<INPUT TYPE="FILE" NAME="FILE" > <INPUT TYPE="SUBMIT" VALUE="Upload" NAME="ACTION" >
</FORM>
To check the size with os.path.getsize(file) I need the filename with the whole path.
How can I get this from the form variables ?
Regards.
Michael
_______________________________________________ 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 )
_______________________________________________ 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 )
_______________________________________________ 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 )
You are confusing things that happen on the client and things that happen on the server. Your server cannot somehow reach back to the client and ask it for the file size. jens On Tuesday, Aug 19, 2003, at 11:01 US/Eastern, Michael Bleijerveld wrote:
Hi Andreas,
This doesn't work for me. When I want to get the filesize of a large file (10 MB or more) I takes a long time to get the result. Therefore I want to use os.path.getsize.
Michael
----- Original Message ----- From: "Andreas Jung" <andreas@andreas-jung.com> To: "Michael Bleijerveld" <michael@bleijerveld.nl>; <zope@zope.org> Sent: Tuesday, August 19, 2003 4:51 PM Subject: Re: [Zope] get full pathname file from form
call len() on the body of the received data. Except MSIE ,you will you receive the filename and not the complete path.
-aj
--On Dienstag, 19. August 2003 16:44 Uhr +0200 Michael Bleijerveld <michael@bleijerveld.nl> wrote:
Hi all,
I want to upload a file with this form.
<FORM ACTION="upload_file" METHOD="POST" ENCTYPE="multipart/form-data">
<INPUT TYPE="FILE" NAME="FILE" > <INPUT TYPE="SUBMIT" VALUE="Upload" NAME="ACTION" >
</FORM>
To check the size with os.path.getsize(file) I need the filename with the whole path.
How can I get this from the form variables ?
Regards.
Michael
_______________________________________________ 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 )
_______________________________________________ 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 Tue, Aug 19, 2003 at 05:01:08PM +0200, Michael Bleijerveld wrote:
Hi Andreas,
This doesn't work for me. When I want to get the filesize of a large file (10 MB or more) I takes a long time to get the result. Therefore I want to use os.path.getsize.
can't possibly work on the server. You don't have access to the file on the client side, you only have access to the uploaded data, which is not on the filesystem. -- Paul Winkler http://www.slinkp.com Look! Up in the sky! It's GIGA GILDED ALLOY FRED! (random hero from isometric.spaceninja.com)
This doesn't work for me. When I want to get the filesize of a large file (10 MB or more) I takes a long time to get the result. Therefore I want to use os.path.getsize.
To check the size with os.path.getsize(file) I need the filename with
the
whole path.
How can I get this from the form variables ?
You can't, unless:
1) you stick it on a filesystem (as a temporary file) 2) or somehow convince Zope to give you a handle to a temporary file it writes on upload, if it does. This probably means mucking about in the core. --jcc
Michael, This returns a File_Upload object. See lib/python/ZPublisher/HTTPRequest.py to see what's under the sheets. On Tue, 19 Aug 2003, Michael Bleijerveld wrote:
Hi all,
I want to upload a file with this form.
<FORM ACTION="upload_file" METHOD="POST" ENCTYPE="multipart/form-data">
<INPUT TYPE="FILE" NAME="FILE" > <INPUT TYPE="SUBMIT" VALUE="Upload" NAME="ACTION" >
</FORM>
To check the size with os.path.getsize(file) I need the filename with the whole path.
How can I get this from the form variables ?
Regards.
Michael
_______________________________________________ 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 )
Michael Bleijerveld wrote at 2003-8-19 16:44 +0200:
I want to upload a file with this form.
<FORM ACTION="upload_file" METHOD="POST" ENCTYPE="multipart/form-data">
<INPUT TYPE="FILE" NAME="FILE" > <INPUT TYPE="SUBMIT" VALUE="Upload" NAME="ACTION" >
</FORM>
To check the size with os.path.getsize(file) I need the filename with the whole path.
How can I get this from the form variables ?
Others already told you that the client side file path will not help you (as, in general, you will not be able to access the file). When Zope starts to handle your request, ZServer has already uploaded your complete file to a temporary file on your server. Depending on the file size, this can take quite long. You can use the file methods "seek(0,2)" (positions at the end of the file) and "tell()" (returns the current position) to determine the files size. Do not forget to reposition at the start of the file ("seek(0") when you want to process it. Dieter
participants (7)
-
Andreas Jung -
Dennis Allison -
Dieter Maurer -
J Cameron Cooper -
Jens Vagelpohl -
Michael Bleijerveld -
Paul Winkler