Menu

#10 temp file rename and strip

open
nobody
None
5
2004-09-08
2004-09-08
Anonymous
No

As mentioned on another post there is a conflict from
the upload2.php and the upload.cgi variables being
saved and called.

I changed the variable in the upload.cgi file (line 177)
from:
$qstring .= "tmp_name[name][$j]=$tmp_filename&";

to:
$qstring .= "file[tmp_name][$j]=$tmp_filename&";

I also added this to upload2.php to help tidy up the
filename so it just used the last part instead of the path
as well

$the_file_name_part[$i] = array_pop(explode("\\", $file
['name'][$i]));

I then used this for renaming ($doc_path being where
on the server I wanted to move the file to):
rename($file['tmp_name'][$i], "$doc_path/
$the_file_name_part[$i]");

Hope the above makes sense and saves somebody some
time.

Apart from the above mentioned problem what a great
tool it is :)

Discussion

  • Nobody/Anonymous

    Logged In: NO

    Agree,

    but i didn't need to split the filename from the path, it was already
    split.

    $the_file_name_part[$i] = array_pop(explode("\\", $file
    ['name'][$i]));

     
  • Nobody/Anonymous

    Logged In: NO

    Ok, just found out that windows needs to have the filename split
    so i do need

    $the_file_name_part[$i] = array_pop(explode("\\", $file
    ['name'][$i]));

    uploading from Mac OS X, doesn't need this.

     

Log in to post a comment.

MongoDB Logo MongoDB