W3Cschool
恭喜您成為首批注冊用戶
獲得88經(jīng)驗(yàn)值獎勵
可以對 input 域使用不同的 name 來上傳多個文件。
PHP 支持同時上傳多個文件并將它們的信息自動以數(shù)組的形式組織。要完成這項(xiàng)功能,需要在 HTML 表單中對文件上傳域使用和多選框與復(fù)選框相同的數(shù)組式提交語法。
示例 #1 上傳多個文件
<form action="file-upload.php" method="post" enctype="multipart/form-data">
Send these files:<br />
<input name="userfile[]" type="file" /><br />
<input name="userfile[]" type="file" /><br />
<input type="submit" value="Send files" />
</form>
當(dāng)以上表單被提交后,數(shù)組 $_FILES['userfile'],$_FILES['userfile']['name'] 和 $_FILES['userfile']['size'] 將被初始化。
例如,假設(shè)名為 /home/test/review.html 和 /home/test/xwp.out 的文件被提交,則 $_FILES['userfile']['name'][0] 的值將是 review.html,而 $_FILES['userfile']['name'][1] 的值將是 xwp.out。類似的,$_FILES['userfile']['size'][0] 將包含文件 review.html 的大小,依此類推。
此外也同時設(shè)置了 $_FILES['userfile']['name'][0], $_FILES['userfile']['tmp_name'][0], $_FILES['userfile']['size'][0] 以及 $_FILES['userfile']['type'][0]。
警告
The max_file_uploads configuration setting acts as a limit on the number of files that can be uploaded in one request. You will need to ensure that your form does not try to upload more files in one request than this limit.
Copyright©2021 w3cschool編程獅|閩ICP備15016281號-3|閩公網(wǎng)安備35020302033924號
違法和不良信息舉報電話:173-0602-2364|舉報郵箱:jubao@eeedong.com
掃描二維碼
下載編程獅App
編程獅公眾號
聯(lián)系方式:
更多建議: