|
Author |
Message |
stepnstomp
Junior WebHelper
Joined: 26 Feb 2002
Posts: 1
|
Posted:
Tue Feb 26, 2002 12:32 am (22 years, 1 month ago) |
|
I'm having a hell of a time trying to get my website admin program working with the file upload feature i've added. The file uploads, with the correct file name, in the correct location, even with the correct file length, yet when the uploaded file is opened it is corrupt!!
My code is...
#!/usr/bin/perl
use CGI;
$cgi = new CGI;
$ft = $cgi->param('ft');
$file = $cgi->param('fl');
$domain = "http://whatever.domain.org";
$err_url = "$domain/err.htm";
$id = $cgi->param('userid');
$pw = $cgi->param('password');
$fa = $cgi->param('FA');
$type = $cgi->uploadInfo($file)->{'Content-Type'};
$desc = "File Upload";
$cmd = $cgi->param('cmd');
$len = length($file);
$pos = $len-3;
$ext = substr($file,$pos,3);
if($file eq ""){$mess="[Upload failed!] - No file selected.";&error;}
else {
if($ft eq "rm"){$dir = "./tmp/mp3";
if($ext ne ".rm"){$mess="[Upload failed!] - Invalid file type selected.";&error;};
};
if($ft eq "mp3"){$dir = "./tmp/mp3";
if($ext ne "mp3"){$mess="[Upload failed!] - Invalid file type selected.";&error;};
};
if($ft eq "jpg"){$dir = "./tmp/images";
if($ext ne "jpg"){$mess="[Upload failed!] - Invalid file type selected.";&error;};
};
if($ft eq "gif"){$dir = "./tmp/images";
if($ext ne "gif"){$mess="[Upload failed!] - Invalid file type selected.";
}
if($ft eq ""){
if($file ne ""){$mess="[Upload failed!] - No file type selected.";&error;
};
}
if($mess eq ""){$mess="[Upload Complete!]<br><br><font color=black><b>$file";}
$file=~m/^.*(\\|\/)(.*)/; # strip the remote path and keep the filename
$name = $2;
open(LOCAL, ">$dir/$name") or die $!;
binmode(LOCAL);
while(<$file>) {
print LOCAL $_;
}
&uploaded;
#### error & uploaded subs ---->>>>
Any help would be great, I don't know what i'm missing, doing, not doing this must be fairly simple to someone who knows a lot more than me, as it is uloading a file, just a bad one!!
also is it possible to then get the perl code to FTP the file once uploaded to another one of our servers giving the code the relevant userid & password details?
cheers,
craig. |
|
|
|
|
|
|
You cannot post new topics in this forum. You cannot reply to topics in this forum. You cannot edit your posts in this forum. You cannot delete your posts in this forum. You cannot vote in polls in this forum.
|
Page generation time: 0.17133 seconds :: 18 queries executed :: All Times are GMT
Powered by phpBB 2.0
© 2001, 2002 phpBB Group :: Based on an FI Theme
| |