Hi,
I'm letting a user upload up tp 5 images from a form.
The form looks like this:
<form action="upload_images.php" method="post" enctype="multipart/form-data" name="form">
Image 1 <input type="file" name="File1">
Image 2 <input type="File" name="File2">
Image 1 <input type="file" name="File3">
Image 2 <input type="File" name="File4">
Image 1 <input type="file" name="File5">
<input type="submit" name="Submit" value="Upload Images">
<input name="type" type="hidden" value="<?php echo $HTTP_GET_VARS['type']; ?>">
<input name="articleID" type="hidden" value="<?php echo $HTTP_GET_VARS['articleID']; ?>">
In the upload script I try using $HTTP_POST_FILES['File$a']['name'] to access each file where $a is incremented in a loop.
// Stor loop
for ($a = 1; $a<=5; $a++) {
$the_name=$HTTP_POST_FILES['File$a']['name'];
echo "Filnamn är: $the_name<br>";
// Kolla om fil 1 finns
if ($HTTP_POST_FILES['File$a']['name'] !="") {
echo "Gått in i loop och tittar på fil $a <br>";
$Fname1 = ereg_replace("å","aa",$HTTP_POST_FILES['File$a']['name']);
$Fname1 = ereg_replace("ä","ae",$Fname1);
$Fname1 = ereg_replace("ö","oe",$Fname1);
$Fname1 = ereg_replace(" ","",$Fname1);
$Fname1 = ereg_replace("%20","",$Fname1);
copy($HTTP_POST_FILES['File$a']['tmp_name'], "$path2$Fname1") or die ("Could not copy the file 1");
}
// Slut koll av fil
}
// Slut stor loop
However - there is never any value in $HTTP_POST_FILES['File$a']['name'] which confuses me. Where have I gone wrong? Is there any settings on the server that can turn this of? I'm setting it up on a new host and I know they got SAFE mode turned on in PHP. However - I can upload the files if I just access File1_name . I would however like to be able to loop since the resulting page other wise would have a lot of repetitive code.
/B