madcgimonk
Programmer
The upload script does upload the file, but it's alwaos 0k in size. For some reason it's uploading the file name but not the file. You notice that when you're uploading via the form, it takes a fraction of a second for it to say the file was uploaded.. so it's not even trying to upload data.
Can anyone see what the problem might be?
Can anyone see what the problem might be?
Code:
if (param("UploadFile"))
{
## collected from form field (the file itself)
my $remotefile = param('upload');
my $filename = $remotefile;
## collected from form field (username)
my $user = param("select");
## strip off directory paths
$filename =~ s/^.*[\\\/]//;
my $localfile = "/home2/spyders/public_html/member/$user/$filename";
# full file path to upload directory (must include $filename)
#############
# Check to see if the file already exists
#############
if(-e "$localfile")
{
print "<center><font color=red>ERROR: A file with that filename already exists. Upload aborted.</font></center>";
exit;
}
####
# open a new file and transfer bit by bit from what's in the buffer
####
open( SAVED, ">>$localfile" );
my $buffer;
while ( my $bytesread = read( $remotefile, $buffer, 1024 ) )
{
print SAVED $buffer;
}
close SAVED;
my $mode = 0755;
chmod $mode, "$localfile";
print "<center><font color=blue>File was uploaded to <b>$user</b> successfully.</font></center>";
}