Here's the basic run down.
~upload.php~
<?
if(isset($FILE))
{
$fileroot = $GLOBALS["DOCUMENT_ROOT"].'files/';
//Make sure directory exists, if not then create it
@mkdir($fileroot, 0777);
if (strlen($FILE_name)>0)
{
//Strip double /'s (Common error on Win32 systems)
$tempfile = stripcslashes($FILE);
$filelocation = $fileroot.$FILE_name;
//If file by same name already exist then delete it (else copy function will fail)
@unlink($oldfile);
if(@copy($tempfile, $newfile))
echo 'File "'.$FILE_name.'" Copied Successfuly.<br><br>';
else
echo 'ERROR - File "'.$FILE_name.'" Copied Failed with the following error message"'.$php_errormsg.'".<br><br>';
}
else
echo 'ERROR - Filename is blank, please try again<br><br>';
}
?>
<form enctype="multipart/form-data" action="/upload.php" method="POST" name="FormUpload">
Filename:<input type="file" size="28" name="FILE"><input type="submit" name="submit">
</form>
The heart of this is in the form's enctype (encoding type), using the multipart/form-data type it can upload as many files are you want, the files are then uploaded to a temporary directory and the following variables are created for you recieving script:
FILE - The location of the tempfile.
FILE_name - The name of the file being uploaded.
FILE_size - The size of the file in bytes.
Where "FILE" is the name of the input item, so an easy way to upload an arbitrary number of files is to use arrrays like so:
<form enctype="multipart/form-data" action="/upload.php" method="POST" name="FormUpload">
Filename:<input type="file" size="28" name="FILE[]"><br>
<input type="file" size="28" name="FILE[]"><br>
<input type="submit" name="submit">
</form>
This would then create a set of variables looking like this:
FILE[] - The array of tempfile locations.
FILE_name[] - The arrray of filenames.
FILE_size[] - The array of file sizes.
Hope this gives ya the basic rundown ok, if not then I cana fill in any gaps ya might need later.