I have two forms that I want to pass the filefield from one form to the other.
The HTML code is as follows:
<html>
<head>
<script>
function CheckForm
{document.pay.photo.value = document.ad.photo.value;
return true;
}
</script>
</head>
<body>
<h1>Upload File</h1>
<form name=”ad” action=”../../cgi-bin/upload.cgi” method=”post” enctype=”multipart/form-data”>
<p>Choose file to upload<input type=”file” name=”photo”>
<p><input type=”submit” value=”Click Here to Upload File Ad”>
</form>
<form name=”pay” action=”../../cgi-bin/upload.cgi” method=”post” enctype=”multipart/form-data”>
<input type=”hidden” value=”photo”>
<p><input type=”submit” value=”Click Here to Upload File Pay “onSubmit=”return CheckForm()”>
</form>
</body>
</html>
And then it calls the following perl script:
#!/usr/bin/perl -w
use CGI;
$query = new CGI;
$upload_dir = “../www/upload/pictures”;
$filename = $query->param(“photo”);
$filename =~ s/.*[/
$_ = $filename;
s/[s|`@#^*()+{}[]:<>|
$filename = $
$email_address = $query->param(“email_address”);
$uploadfilename = $upload_dir.”/”.$filename;
$upload_filehandle = $query->upload(“photo”);
open UPLOADFILE, “>$uploadfilename”;
while (<$upload_filehandle>)
{
print UPLOADFILE;
}
close UPLOADFILE;
print $query->header ( );
print <<“ENDOFHTML”;
<HEAD>
<TITLE>Thanks</TITLE>
</HEAD>
<BODY>
<P>Thanks for uploading your photo
<P>Your photo:
<img src=”../upload/pictures/$filename” border=”0″>
</BODY>
</HTML>
ENDOFHTML
exit;
When I hit the submit button for the “ad” form it uploads the file correctly, but when I hit the submit button for the “pay” form it fails.
How do I successfully assign a filetype element to the hidden element of the other form?
The html is located in [url]http://www.fruit-tree.com/upload/upload1.html
Thanks,
Marc