Hello all-
I'm trying to write a script that will upload a file from a web page and
store that file on the web server. I've snipped out the piece of code below
that's supposed to do this for me. This is running under use CGI
':standard'; use strict; and use warnings without any errors.
# $file is the full path of the file and file name submitted from the form.
# $upload_path looks like d:/upload_files/
I believe the problem is in the while loop. The conditional if returns
true and the file gets created with the correct name in the correct path
(so I know the permissions are correct on the server) but I never see the
"Hello' prints in the browser and the file never grows past 0kb. For some
reason I guess it isn't reading in the file from the client browser. What
have I missed? I checked a couple locations on CPAN for upload scripts and
they perform the same basic operation. I even snipped parts of those
scripts and used them in place of my upload process but I've arrived at the
same result. I'd appreciate any direction you may have.
###---Here are the relevant secions of code
print "Content-type: text/html\n\n";
print "<html>\n";
print "<head>\n";
print "<body>\n";
if ($file) {
my @fileparts=split(/\\/,$file);
my $file_name=pop(@fileparts);
open (UPLOAD, ">$upload_path/$file_name") || die "Can't open file\n";
my ($data,$length,$chunk);
while ($chunk = read ($file,$data,1024)) {
print UPLOAD $data;
print "Hello!<br>\n";
}
close UPLOAD;
}
~Thanks!
Mike
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
- Re: Problem with While condition in file upload Mike Garner
- Re: Problem with While condition in file upload Rob Dixon
- Re: Problem with While condition in file upload John W. Krahn