The code below is for an upload script that uploads multiple files. It works good. But there are a couple of things that I cannot, or have not yet, got figured out.
I hesitate to put code, where I don't know exactly how the code works, into my web site.
First, in the fifth line below, I don't see how the "fileup$Number"."name" value works. In other words, if I replace the "name" part of the code with something like "abc" it won't work. I can't find where the phrase "name" is included within the PHP programming language. I don't see why "abc" or "xyz" won't work just as well as "_name".
Also the variable assignment phrase "$OriginalFileName = $$PictureFirst" outputs the name of the file (ex. CarPicture1.gif or BoatPicture2.gif). It looks like that the variable assignment "$OriginalFileName" would be "fileup$Number"."_name" instead of the actual name of the image.
One more thing - the "none" in the "if($TemporaryFile!="none")" function is not a PHP reserved function, I don't think. I cannot find the word "none" in the PHP manual. I've replaced the word "none" with the variable "NULL" and the script will not work. I've also tried replacing the word "none" with the letters "abc" - it won't work. I can't understand why the word "none" must be used.
I would appreciate any explanations that anyone could provide.
$Admin[UploadNum] = "10"; // Number of upload fields to put on the html page
$Admin[Directory] = "uploads";
if($FileUpload) {
for ($Number = 1; $Number <= $Admin[UploadNum]; $Number++){
$PictureFirst = "fileup$Number"."_name";//Set format for variable $OriginalFileName
$OriginalFileName = $$PictureFirst;//Somehow outputs the original file name.
$SetFormatTempFile = "fileup$Number";//Set format for variable $TemporaryFile
$TemporaryFile = $$SetFormatTempFile;
if($TemporaryFile != "none") {
$Filesizebtyes = filesize($TemporaryFile);
$ok = 1;
if($Filesizebtyes < 10) {
$error .= "Error uploading (file size lower than 10 bytes) for file $Number<BR>";
$ok = 2;
}
if(file_exists("$Admin[Directory]/$OriginalFileName") OR $ok == 2) {
$error .="File name already exists for file $Number<BR>";
} else {
copy ($TemporaryFile, "$Admin[Directory]/$OriginalFileName");
$error .="File $Number has been uploaded<BR>";
}
}
}
if(!$error) {
$error .= "No files have been selected for upload";
}
echo $error;
exit();
} else {
echo "<form enctype=\"multipart/form-data\" action=\"uploader.php\" method=\"post\">\n";
for ($Number = 1; $Number <= $Admin[UploadNum]; $Number++){
echo "<input name=\"fileup$Number\" type=\"file\" size=\"25\">\n";
}
echo "<input name=\"FileUpload\" type=\"submit\" value=\"Upload Files\">\n";
exit();
}
Thanks.
Volitics