|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Hi all,
i have searched the forums but didn't find an answer for my problem... i have a HTML form where the user can upload a file. input type=file name=localfile value="*.*" but when i try to get the data in the CGI script the filehandle is always undefined: my $fh=$cgi->upload('localfile'); if (!$fh) { return 'Error while reading data.'; } My form is 'enctype="multipart/form-data"', even $cgi->Dump() shows that localfile is undefined, although i can see that the browser is uploading the data. I also tried $cgi->param('localfile') but it returned undef too...What am i doing wrong? Chris. |
|
#2
|
|||
|
|||
|
According to a book i have on my lap (O'Reilly CGI Programming) if you have a form like this:
(form already started) Code:
<P>Please choose a file to upload <INPUT TYPE=FILE NAME="file"> <P>Please enter the name of the file <INPUT TYPE=FILE NAME="filename"> then you can get the file handle for the temp. file where it is stored by doing this: Code:
my $file = $q->param( "file" ); my $fh = $q->upload( $file ); |
|
#3
|
|||
|
|||
|
No, this does not work:
in my form: <input type="file" name="localfile" value="*.*"> in the script: my $fn=$cgi->param('localfile'); if (!$fn) { return 'No filename - Error while reading data.'; } $fh=$cgi->upload($fn); if (!$fh) { return 'No filehandle - Error while reading data.'; } The filename is always undefined! The error must be somewhere else but i can't find it ![]() |
|
#4
|
|||
|
|||
|
Couple of things i would try then (being too lazy to try it myself :P )
Try change the name of param. that the file is uploaded under (in other words change 'localfile' to 'lofile' ) Put $fn as some string (actually in the script) and comment out the upload line. If it still doesn't work, something is then wrong with your programming. Expand the (!$fn) to ($fn eq undef). Make things as uncomplicated as possible, using no fancy shortcuts. Failing that, copy and paste it all to another file and save it (it has fixed some of my script problems!!) |
|
#5
|
|||
|
|||
|
Hi Acid Reign,
thanks for your nice help; i just found my problem... The CGI object was created in another file, by chance i saw that HTML uploads were disabled... ($CGI: ISABLE_UPLOADS=1)arghllll!! Chris ![]() |
![]() |
| Viewing: Dev Shed Forums > Programming Languages > Perl Programming > HTML file upload and CGI module |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|