H
Hal Vaughan
I've written Perl scripts to upload files before, but I'm having a lot of
problems getting it to work in this case. I have a form with nothing
outstanding about it and I'm simply trying to use the CGI:aram(filename)
to get the handle so I can read from it and write it to a file on my web
server.
I've snipped the other parts, since the form and Perl code would be long.
Here's the basic form:
<form method="post" action="/perl/upload.pl" name="DataUpload">
UploadData: <input name="uploaddata" type="file">
<input name="UploadData" value="Submit" align="left" type="submit">
</form>
And here's what I have in my upload.pl script:
(again, the relevant parts, only)
use CGI;
$fname = CGI:aram("file");
$fdata = CGI:aram("data");
# $uhandle = CGI:aram("uploaddata");
$uhandle = CGI::upload("uploaddata");
$tfile = "/var/www/data/temp.upload";
open OUT, ">$tfile";
binmode OUT;
$fdata = <$uhandle> or cgilog("DEBUG Upload Error: $!");
print OUT $fdata;
close OUT;
At this point I'm only testing this with a text file that is less than 50
bytes long, so I'm not worried about reading in too much data at once.
Once I've got it working, I'll replace that with a loop to read from the
file handle with a specified buffer length and write to the output.
cgilog() is my own logging routine that just dumps the log statements to a
log file. In this case, I keep getting either "No such file or directory"
as the error or no error reported at all. I also have uncommented the
commented out line and used that to replace the line above it. It makes no
difference.
My guess is this is something extremely simple and obvious that I expect to
be doing that I'm not because I've gone over this many times and spent
hours on Google to try to find what I'm doing wrong, but I can't find a
thing.
This is for a system running Apache (1.3) on Linux.
Thanks for any help.
Hal
problems getting it to work in this case. I have a form with nothing
outstanding about it and I'm simply trying to use the CGI:aram(filename)
to get the handle so I can read from it and write it to a file on my web
server.
I've snipped the other parts, since the form and Perl code would be long.
Here's the basic form:
<form method="post" action="/perl/upload.pl" name="DataUpload">
UploadData: <input name="uploaddata" type="file">
<input name="UploadData" value="Submit" align="left" type="submit">
</form>
And here's what I have in my upload.pl script:
(again, the relevant parts, only)
use CGI;
$fname = CGI:aram("file");
$fdata = CGI:aram("data");
# $uhandle = CGI:aram("uploaddata");
$uhandle = CGI::upload("uploaddata");
$tfile = "/var/www/data/temp.upload";
open OUT, ">$tfile";
binmode OUT;
$fdata = <$uhandle> or cgilog("DEBUG Upload Error: $!");
print OUT $fdata;
close OUT;
At this point I'm only testing this with a text file that is less than 50
bytes long, so I'm not worried about reading in too much data at once.
Once I've got it working, I'll replace that with a loop to read from the
file handle with a specified buffer length and write to the output.
cgilog() is my own logging routine that just dumps the log statements to a
log file. In this case, I keep getting either "No such file or directory"
as the error or no error reported at all. I also have uncommented the
commented out line and used that to replace the line above it. It makes no
difference.
My guess is this is something extremely simple and obvious that I expect to
be doing that I'm not because I've gone over this many times and spent
hours on Google to try to find what I'm doing wrong, but I can't find a
thing.
This is for a system running Apache (1.3) on Linux.
Thanks for any help.
Hal