I tried a couple of methods here to no avail. This works for me.
Near line 175 in upload.cgi I added the line: $fh = substr $fh, 1 + rindex $fh, '\\'; Between the close and the move statements.
Here's the end result: close($tmp_fh); $fh = substr $fh, 1 + rindex $fh, '\\'; move($tmp_filename, $target_dir."/".$fh) || warn $!;
In upload.cgi near the end.
for($i=0, $j=0; $i < $size ; $i++) { $file_upload = $cg->param("file[$i]"); if(defined ($file_upload)) { my $fh = $cg->upload("file[$i]"); $fn = substr $fh, 1 + rindex $fh, '\\'; #Insert this line $fsize =(-s $fh); print "<tr class='help'><td>$fn</td>\n"; #edit this line if ($fsize > 0) { print "<td>$fsize <b>KB</b></td>"; #a hack to display KB } . . . open (OUTFILE,">>/home/my_user/$fn"); #edit this line while(<$fh>) { print OUTFILE $_; } close(OUTFILE);
Log in to post a comment.
I tried a couple of methods here to no avail. This works for me.
Near line 175 in upload.cgi I added the line:
$fh = substr $fh, 1 + rindex $fh, '\\';
Between the close and the move statements.
Here's the end result:
close($tmp_fh);
$fh = substr $fh, 1 + rindex $fh, '\\';
move($tmp_filename, $target_dir."/".$fh) || warn $!;
In upload.cgi near the end.
for($i=0, $j=0; $i < $size ; $i++)
{
$file_upload = $cg->param("file[$i]");
if(defined ($file_upload)) {
my $fh = $cg->upload("file[$i]");
$fn = substr $fh, 1 + rindex $fh, '\\'; #Insert this line
$fsize =(-s $fh);
print "<tr class='help'><td>$fn</td>\n"; #edit this line
if ($fsize > 0) {
print "<td>$fsize <b>KB</b></td>"; #a hack to display KB
}
.
.
.
open (OUTFILE,">>/home/my_user/$fn"); #edit this line
while(<$fh>) {
print OUTFILE $_;
}
close(OUTFILE);