i have used jp's file upload script but my problem is, the files i am uploading are not being saved into the server when i use remote machines. however, if i access my dbman page on the server itself, it does could transfer/upload files.
here's some parts of my script:
binmode(STDIN);
binmode(STDOUT);
binmode(STDERR);
foreach $key (sort {$a <=> $b} $query->param()) {
next if ($key =~ /^\s*$/);
next if ($query->param($key) =~ /^\s*$/);
next if ($key !~ /^file-to-upload-(\d+)$/);
$Number = $1;
if ($query->param($key) =~ /([^\/\\]+)$/) {
$Filename = $1;
$File_Handle = $query->param($key);
$File_Handle =~ s/\s+//g;
print $query->redirect("$db_script_link_url&$db_key=$rec{$db_key}&upload_success=1&newfilename=$File_Handle");
undef $BytesRead;
undef $Buffer;
while ($Bytes = read($File_Handle,$Buffer,1024)) {
$BytesRead += $Bytes;
binmode(OUTFILE);
print OUTFILE $Buffer;
}
push(@Files_Written, "$SAVE_DIRECTORY\/$Filename");
$TOTAL_BYTES += $BytesRead;
$Confirmation{$File_Handle} = $BytesRead;
close($File_Handle);
close(OUTFILE);
chmod (0666, "$SAVE_DIRECTORY\/$Filename");
}
$FILES_UPLOADED = scalar(keys(%Confirmation));
if ($TOTAL_BYTES > $MAXIMUM_UPLOAD && $MAXIMUM_UPLOAD > 0) {
foreach $File (@Files_Written) {
unlink $File;
}
$message = "You have reached your upload limit. You attempted to upload a file with
<B>$TOTAL_BYTES</B>. This exceeds the maximum limit of <B>$MAXIMUM_UPLOAD</B> bytes, set by the system
administrator. Your file was <B>NOT</B> successfully saved. Please try again.";
&html_upload_failure($message);
exit;
}
print $query->redirect("$db_script_link_url&$db_key=$rec{$db_key}&upload_success=1&newfilename=$File_Handle");
here's some parts of my script:
binmode(STDIN);
binmode(STDOUT);
binmode(STDERR);
foreach $key (sort {$a <=> $b} $query->param()) {
next if ($key =~ /^\s*$/);
next if ($query->param($key) =~ /^\s*$/);
next if ($key !~ /^file-to-upload-(\d+)$/);
$Number = $1;
if ($query->param($key) =~ /([^\/\\]+)$/) {
$Filename = $1;
$File_Handle = $query->param($key);
$File_Handle =~ s/\s+//g;
print $query->redirect("$db_script_link_url&$db_key=$rec{$db_key}&upload_success=1&newfilename=$File_Handle");
undef $BytesRead;
undef $Buffer;
while ($Bytes = read($File_Handle,$Buffer,1024)) {
$BytesRead += $Bytes;
binmode(OUTFILE);
print OUTFILE $Buffer;
}
push(@Files_Written, "$SAVE_DIRECTORY\/$Filename");
$TOTAL_BYTES += $BytesRead;
$Confirmation{$File_Handle} = $BytesRead;
close($File_Handle);
close(OUTFILE);
chmod (0666, "$SAVE_DIRECTORY\/$Filename");
}
$FILES_UPLOADED = scalar(keys(%Confirmation));
if ($TOTAL_BYTES > $MAXIMUM_UPLOAD && $MAXIMUM_UPLOAD > 0) {
foreach $File (@Files_Written) {
unlink $File;
}
$message = "You have reached your upload limit. You attempted to upload a file with
<B>$TOTAL_BYTES</B>. This exceeds the maximum limit of <B>$MAXIMUM_UPLOAD</B> bytes, set by the system
administrator. Your file was <B>NOT</B> successfully saved. Please try again.";
&html_upload_failure($message);
exit;
}
print $query->redirect("$db_script_link_url&$db_key=$rec{$db_key}&upload_success=1&newfilename=$File_Handle");