2016-03-17 42 views
0

[解決前面的問題]

我下載的圖片上傳腳本,使用Ajax和jQuery的作品。我想將最大上傳限制爲8張圖片。請幫忙。圖像使用Ajax和jQuery上傳的PHP

從網上下載:http://www.phpgang.com/how-to-upload-multiple-images-jquery-ajax-using-php_453.html

+0

你是否在控制檯上發現任何錯誤..你是否也在那裏更改文件夾位置? – santosh

+0

沒有...控制檯是空白的..沒有錯誤.. –

+0

沒有..沒有位置改變..所有在位.. –

回答

0

計數的所有文件,並檢查是否有文件超過8與否,如果有超過8發送消息和退出;

像這樣

$fileCount = count($_FILES["myfile"]['name']); 

if($fileCount>8){ 
$data['code'] = "failed"; 
print_r(json_encode($data));exit; 
} 

,並在你的Ajax做任何你想做的事..

0

嘗試這樣的事情。

$allfiles = count($_FILES); 
if($allfiles > 8) 
{ 
    echo "Sorry You can Upload Only 8 images"; 
} 
else{ 
    //your code here 
}