MySQL Forums
Forum List  »  Perl

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

thanx felix,but still now i fetch some problem means i cant see (cant upload) the picture though already i change my url to directory.
Right now my code is as following:For html form
#!/usr/bin/perl -w

print "Content-type: text/html\n\n";
print <<html1;
<html>
<body>
<form action="file_upload.pl"
method="post" enctype="multipart/form-data">
<input type="file" name="photo">
<input type="submit" value="submit">
</form>
</body>
</html>
html1
///////////////////////////////////////////////////////////////////////////////////////////////
and for file uploading cgi script look like this:
#!/usr/bin/perl -w

use CGI;
$upload_dir = "httpd/html/guest4/load";
$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/load/$filename"; border=0'>

</BODY>
</HTML>
END_HTML

plz help felix.

Options: ReplyQuote


Subject
Written By
Posted
Re: help for file uploading in perl
May 16, 2005 04: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.