I am trying to upload a file. I am following the example presented in the apache.org/embperl site.

As in the example, if the file handle isn't defined, I accept the file name from the user.

print "<FORM METHOD=POST ENCTYPE='multipart/form-data'>";
print "<INPUT TYPE=FILE NAME='UserFile'>";

In the second pass, I display the data back to the user

while (@buffer = <$UserFile>) {print "<P> $buffer";}

and put up a button which will submit a hidden field  to indicate the user has accepted the data.

print "<FORM METHOD=POST ACTION='myprogram.mpl'>";
print "<INPUT TYPE=HIDDEN NAME='UserFile' VALUE='$UserFile'>";
print "<INPUT TYPE=HIDDEN NAME='userApproval' VALUE='Y'>";
print "<INPUT TYPE=SUBMIT VALUE='Post this data?'>";
print "</FORM>";

On my third pass, I have lost control of the file. The scalar  $UserFile has the path and file name, but I cannot make use of it. Although I never opened the file to read it before,

@buffer = <UserFile>;
print "<P> \$buffer0 $buffer[0]";

now gives me nothing, and

print "<P> Error openning $UserFile \$UserFile" if (!open(FILE, '$UserFile'));

always fails.

Any suggestions?
Why didn't I have to open the file to read the data?

Thanks,
Jim



Jim Hamer

Downtown Data Processing Inc.
(416) 489-3298 home and office
[EMAIL PROTECTED]
Toronto, Ontario, Canada
http://webhome.idirect.com/~jhamer/

Reply via email to