Home > Archive > PERL Programming > March 2004 > CGI:upload hadler - newbie question
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
CGI:upload hadler - newbie question
|
|
|
| Hi All,
I try to handle a file uploading with the CGI. The CGI manpage give me a
way. But I can not hendle the file, just the file name with MSIE. And got
nothing with Safari.
I use macosx.
Here is my script:
#!/usr/bin/perl
use CGI;
$query = new CGI;
print $query->header;
$filename = $query->param('upload_file');
print "$filename+OK"; #works!
# does not work!
$fh = $query->upload ('upload_file');
while (<$fh> ) {
print;
}
Any body can help me?
--
I like Q but please remove 'Q' from my email address.
| |
| Joe Smith 2004-03-18, 6:46 pm |
| Habul wrote:
> I try to handle a file uploading with the CGI. The CGI manpage give me a
> way. But I can not hendle the file, just the file name with MSIE.
The doc for CGI says:
In order to take full advantage of this you must use the new
multipart encoding scheme for the form. You can do this either
by calling start_form() with an encoding type of &CGI::MULTIPART,
or by calling the new method start_multipart_form() instead of
vanilla start_form().
Since the code you posted did not use start_multipart_form(), that
may be your problem.
-Joe
| |
|
| Thanks Joe,
I miss:
enctype="multipart/form-data"
On 2/18/04 1:26 AM, Joe Smith wrote:
> Since the code you posted did not use start_multipart_form(), that
> may be your problem.
start_multipart_form() generates the line in our form.
--
I like Q but please remove 'Q' from my email address.
| |
| Matt Garrish 2004-03-18, 6:46 pm |
|
"Habul" <eshabeQ@hotPOP.com> wrote in message
news:BC57A078.542E%eshabeQ@hotPOP.com...
> Hi All,
>
> I try to handle a file uploading with the CGI. The CGI manpage give me a
> way. But I can not hendle the file, just the file name with MSIE. And got
> nothing with Safari.
>
>
> #!/usr/bin/perl
>
> use CGI;
>
> $query = new CGI;
>
>
> print $query->header;
>
> $filename = $query->param('upload_file');
> print "$filename+OK"; #works!
>
> # does not work!
> $fh = $query->upload ('upload_file');
>
Nothing is perfect:
http://stein.cshl.org/WWW/software/...#upload_caveats
I don't remember the specifics anymore, but I did run into a similar problem
with uploads in IIS. Reverting back to the original example in the
documentation cleared the problem up, though:
# Read a text file and print it out
while (<$filename> ) {
print;
} # Copy a binary file to somewhere safe
open (OUTFILE,">>/usr/local/web/users/feedback");
while ($bytesread=read($filename,$buffer,1024)
) {
print OUTFILE $buffer;
}
Matt
|
|
|
|
|