我使用免费的网络主机作为我的php脚本,这是我的代码
print_r($_FILES);
for($i=0;$i<5;$i++){
echo "file name =".$_FILES['file'.$i]['name'];
$file_name = $_FILES['file'.$i]['name'];
if($file_name){
$ext = end((explode(".", $file_name)));
echo "<br>flag = $ext <br>";
// strip file_name of slashes
$file_name = stripslashes($file_name);
$file_name = str_replace("'","",$file_name);
$file_name = "Produit".$idp."-".$i.".".$ext;
$copy = copy($_FILES['file'.$i]['tmp_name'],"ProduitImages/".$idproduit."/".$file_name);
// prompt if successfully copied
if($copy){
echo "$file_name | uploaded sucessfully!<br>";
}else{
echo "$file_name | could not be uploaded!<br>";
}
}{
echo "<br>file $i not sent<br>";
}
&#13;
在我的本地主机上它没有任何问题。
那么,为什么在主机中$ _Files是空的以及如何解决它?非常感谢。
这是我的HTML代码
<div class="input-file-container">
<label for="my-file" class="input-file-trigger" tabindex="0">please Select all 5 images </label>
<input class="input-file" id="file0" name="file0" type="file">
<input class="input-file" id="file1" name="file1" type="file">
<input class="input-file" id="file2" name="file2" type="file">
<input class="input-file" id="file3" name="file3" type="file">
<input class="input-file" id="file4" name="file4" type="file">
</div>
&#13;
这是结果
Array ( )
Notice: Undefined index: file0 in /home/vhosts/websitename.freeoda.com/Name/includes/vishandler.php on line 131
file name =
Notice: Undefined index: file0 in /home/vhosts/websitename.freeoda.com/Name/includes/vishandler.php on line 132
file 0 not sent
Notice: Undefined index: file1 in /home/vhosts/websitename.freeoda.com/Name/includes/vishandler.php on line 131
file name =
Notice: Undefined index: file1 in /home/vhosts/websitename.freeoda.com/Name/includes/vishandler.php on line 132
file 1 not sent
Notice: Undefined index: file2 in /home/vhosts/websitename.freeoda.com/Name/includes/vishandler.php on line 131
file name =
Notice: Undefined index: file2 in /home/vhosts/websitename.freeoda.com/Name/includes/vishandler.php on line 132
file 2 not sent
Notice: Undefined index: file3 in /home/vhosts/websitename.freeoda.com/Name/includes/vishandler.php on line 131
file name =
Notice: Undefined index: file3 in /home/vhosts/websitename.freeoda.com/Name/includes/vishandler.php on line 132
file 3 not sent
Notice: Undefined index: file4 in /home/vhosts/websitename.freeoda.com/Name/includes/vishandler.php on line 131
file name =
Notice: Undefined index: file4 in /home/vhosts/websitename.freeoda.com/Name/includes/vishandler.php on line 132
file 4 not sent
&#13;