如何循环$ _FILES? [英] How to loop through $_FILES?
问题描述
我想在$ _FILES []数组中添加循环。我尝试了 $ count = count($ _ FILES ['files'] [name])
,然后为它添加循环($ i = 0; $ i <= $ count; $ i ++)
,但它没有给我所需的输出。
我只想从用户正在上传的文件中添加循环,现在它正在计算表单中可用的所有文件。
请告诉我一种方法,只计算上传的文件并循环播放。
$ _ FILES
数组并使用<$ c $ $ $ codeount $($ _ FILES)$ c $ [$ name]] ['files'])
for($ i = 0; $ i <= $ count; $ i ++){
if($ _FILES ['files'] [$ i] ['size'] )
echo $ _FILES ['files'] [$ i] ['name']。\\\
;
}
更容易的是使用foreach循环:
foreach($ _ FILES ['files'] as $ file){
if($ file ['size'])
echo $文件[ '名称'] \\\
。
}
I want to add loop around $_FILES[] array. I tried $count= count($_FILES['files'][name])
and then add loop around it for($i=0; $i<=$count; $i++)
, but it is not giving me desired output.
I want add to loop only from the files that the User is uploading, Right now it is counting all of the 'files' available in the form.
Kindly tell me a way to count only the uploaded files and loop through them.
Loop ever the $_FILES
array and use the ['name']
inside the iteration:
$count = count($_FILES['files'])
for($i=0; $i<=$count; $i++) {
if ($_FILES['files'][$i]['size'])
echo $_FILES['files'][$i]['name']."\n";
}
Even easier is to use a foreach loop:
foreach($_FILES['files'] as $file) {
if($file['size'])
echo $file['name']."\n";
}
这篇关于如何循环$ _FILES?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!