codejone has asked for the wisdom of the Perl Monks concerning the following question:
it recives the post from a HTML form similar to this:#!/usr/bin/perl use CGI; $query = new CGI; $filename = $query->param('photo'); #remove slashes $filename =~ s/.*[\/\\](.*)/$1/; $upload_filehandle = $query->upload('photo'); open UPLOADFILE, ">>/path/to/$filename" ; binmode UPLOADFILE; while ( <$upload_filehandle> ) { print UPLOADFILE; } close UPLOADFILE; print $query->header( ); print <<EOM; <HTML> <HEAD> <TITLE>Thanks!</TITLE> </HEAD> <BODY> <P>Thanks for uploading your file!</P> <P>Your photo:</P> <img src="/$uploaddir/$filename" border="0"> </BODY> </HTML> EOM
<FORM ACTION="/cgi-bin/test.pl" METHOD="post" ENCTYPE="multipart/form-data"> Photo to Upload: <INPUT TYPE="file" NAME="photo"> <INPUT TYPE="submit" NAME="Submit" VALUE="Submit Form"> </FORM>
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Binary File Upload
by samtregar (Abbot) on Dec 05, 2007 at 23:01 UTC | |
|
Re: Binary File Upload
by moritz (Cardinal) on Dec 05, 2007 at 23:05 UTC | |
|
Re: Binary File Upload
by almut (Canon) on Dec 05, 2007 at 22:24 UTC | |
|
Re: Binary File Upload
by aquarium (Curate) on Dec 05, 2007 at 22:40 UTC | |
|
Re: Binary File Upload
by tachyon-II (Chaplain) on Dec 05, 2007 at 23:18 UTC | |
|
Re: Binary File Upload
by Anonymous Monk on Dec 05, 2007 at 23:14 UTC | |
by aquarium (Curate) on Dec 06, 2007 at 00:06 UTC |