Page 1 of 1

Uploading files

Posted: Wed Jul 03, 2002 6:15 am
by ozmodiar
I have been using this script for uploading files. Info is sent from a file field in a HTML form to a page where the upload_file() function is called.

Code: Select all

function upload_file()
{
$archive_dir="./temp";

global $userfile, $userfile_name, $archive_dir, $WINDIR;

if(isset($WINDIR)) $userfile = str_replace("\&quote;, "&quote;, $userfile);
$filename = basename($userfile_name);
if(!@copy($userfile, "$archive_dir/$filename"))
die("Can't copy $userfile_name to $filename.");
@unlink($userfile);

}
This script was working perfectly on my old vertsion of PHP but now it is not working on version 4.2. I am aware of some of the differences in version 4.2 but none of the changes I have made work.

Can anyone tell me how to modify this script to work on PHP4.2? :?

Posted: Wed Jul 03, 2002 9:13 am
by RandomEngy
Read this.

Posted: Wed Jul 03, 2002 3:30 pm
by ozmodiar
As I said earlier I am aware of the differences in php4.2. I have tried using $_POST and $GLOBALS. Neither of these have worked.

Anyone else got any ideas?

Posted: Wed Jul 03, 2002 3:59 pm
by RandomEngy
Maybe you could try using move_uploaded_file() instead of copy?