Hey all,
Solution found! And it works!!!
here are the HTML fields:
uploadfile1, uploadfile2, uploadfile3, uploafile4.
Here is the complete php solution to simplifying (sorta) the 4 different file uploads.:
<?php
// global variables used in other places.
global $uploadfile1, $uploadfile2, $uploadfile3, $uploadfile4;
global $uploadfile_name1, $uploadfile2_name, $uploadfile3_name, $uploadfile4_name;
global $upload_dir, $filename, $filename2, $filename3, $filename4, $filenames;
global $thetime, $MAX_FILE_SIZE, $user;
if ($user == ""){
?>
<BODY>
<H1> Please go back and enter a user name.</H1>
</BODY>
<?php
exit;
} else {
$server_dir = "/home/httpd/webupload";
$thetime = time();
umask(000);
mkdir("$server_dir/$user".""."$thetime",0777);
// Wherever you have write permission below...
$upload_dir = "$server_dir/$user".""."$thetime";
// Gets the temp_name in to a string variable
$uploadtemp1 = $uploadfile1;
$uploadtemp2 = $uploadfile2;
$uploadtemp3 = $uploadfile3;
$uploadtemp4 = $uploadfile4;
// Gets those names into an array to be called later
$original = array(
"$uploadtemp1"
,"$uploadtemp2"
,"$uploadtemp3"
,"$uploadtemp4"
);
// Same as above except gets the real file name
$uploadreal1 = $uploadfile1_name;
$uploadreal2 = $uploadfile2_name;
$uploadreal3 = $uploadfile3_name;
$uploadreal4 = $uploadfile4_name;
$file = array(
"$uploadreal1"
,"$uploadreal2"
,"$uploadreal3"
,"$uploadreal4"
);
// Copy handler for the above arrays. It Works!!!
for($I = 0; $I <=3; $I++){
echo "file number: $I, filename: $file[$I], original name: $original[$I]<BR>";
//$file[$I] = ereg_replace(" ", "", $uploadfile$I_name);
//$file[$I] = ereg_replace("%20", "", $uploadfile$I_name);
$copyfile = "$upload_dir/$file[$I]";
@copy($original[$I], $copyfile);
@unlink($original[$I]);
} // end of for
} // end of else
Kind of a stinkin' shame to have to use arrays, but if I need to change the meat (copy/upload) code for the script, I only have to do it once (right or wrong hehe).
Thanks all. I'll also post to php.net/multiple file uploads
-Wes