Uploading files

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
ozmodiar
Forum Commoner
Posts: 35
Joined: Sat Jun 01, 2002 6:29 am
Location: Dublin, Ireland

Uploading files

Post 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? :?
User avatar
RandomEngy
Forum Contributor
Posts: 173
Joined: Wed Jun 26, 2002 3:24 pm
Contact:

Post by RandomEngy »

Read this.
ozmodiar
Forum Commoner
Posts: 35
Joined: Sat Jun 01, 2002 6:29 am
Location: Dublin, Ireland

Post 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?
User avatar
RandomEngy
Forum Contributor
Posts: 173
Joined: Wed Jun 26, 2002 3:24 pm
Contact:

Post by RandomEngy »

Maybe you could try using move_uploaded_file() instead of copy?
Post Reply