Here's how I do it:
This is the page that prompts the user to upload a file, we'll call it fileselect.php -
<form action="getfile.php" method="post" ENCTYPE="multipart/form-data" name="myform">
<input type="hidden" name="MAX_FILE_SIZE" value='10000'>
<input type="file" accept="text" name="userfile">
<input type="submit" value="upload">
This is the page that puts the file in the directory that you disire-
<?PHP
path = "/path/to/imagedirectory/";
if ( (file_exists($userfile)) ) {
chdir($path);
copy($userfile, "$path/$userfile_name");
}
?>
becuase you called the file "userfile" in the first page and you don't know what the uploader originally named that file (somefile.txt?), you can refer to that file as $userfile_name. Right after the if statement (and before the ?> )on page two, I like to rename the file so that I know what to call it in the future. Here's how:
chdir($path);
$newFileName = "whatever_name_you_want";
rename ("$userfile_name", "$newFileName");