MySQL Forums
Forum List  »  Perl

help for file uploading in perl
Posted by: Devashish Saha
Date: May 16, 2005 01:21AM

i cannot upload a file in my local server from IE.
code for html page
#!/usr/bin/perl

print "Content-type: text/html\n\n";
print <<html1;
<html>
<body>
<form action="http://192.168.0.95/httpd/html/guest4/file_upload.pl"; method="post" enctype="multipart/form-data">
<input type="file" name="photo">
<input type="submit" value="submit">


</form>
</body>
</html>

html1
--------------------------------------------------------------------
code for uploading


#!/usr/bin/perl -w

use CGI;
$upload_dir = "http://192.168.0.95/httpd/html/guest4";;
$query = new CGI;
$filename = $query->param("photo");
$filename =~ s/.*[\/\\](.*)/$1/;
$upload_filehandle = $query->upload("photo");
open UPLOADFILE, ">$upload_dir/$filename";
binmode UPLOADFILE;
while ( <$upload_filehandle> )
{
print UPLOADFILE;
}
close UPLOADFILE;


print "Content-type: text/html\n\n";
print $query->header ( );

print <<END_HTML;
<html>
<HEAD>
<TITLE>Thanks!</TITLE>
</HEAD>

<BODY>

<P>Thanks for uploading your photo!</P>
<P>Your photo:</P>
<img src="http://192.168.0.95/httpd/html/guest4/$filename"; border="0">

</BODY>
</HTML>
END_HTML

Options: ReplyQuote


Subject
Written By
Posted
help for file uploading in perl
May 16, 2005 01:21AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.