问题描述
我正在尝试使用上传多张照片
I m trying to upload multiple photos using
<input type='file'>
与输入元素具有相同名称的
,
with same name to the input element like,
<?php
$remainGal = $maxGallery-$totalGallery;
if($remainGal>0){
?>
<div class="businessSPGItems">
<form name="addBusinessGallery" method="post" action="businessservices.php#messageGallery" enctype="multipart/form-data">
<input type="hidden" name="businessID" value="<?php echo $businessID;?>" />
<?php
for($i=0; $i<$remainGal; $i++){
?>
<input type="file" name="filePhotos[]" style="margin-top:5px;" tabindex="<?php echo $i+5; ?>" /><br />
<?php
}
?>
<input type="submit" name="btnAddGallery" value="Add" style="margin-top:10px;" tabindex="<?php echo $i+5; ?>" />
</form>
</div>
<?php
}
?>
但是问题是当我计算文件元素的总数时,它总是显示5 ...即
But the problem is when i m taking the total count of the file element it always shows 5...ie.,
<?php
$photos = $_FILES["filePhotos"];
echo count($photos);
?>
所以我一次不能上传超过5张照片.我不知道我在做正确的方法.请帮忙,,谢谢...
So i could not upload more than 5 photos at a time....i dont know i m doing the correct method..help please,,thanks...
推荐答案
您的$_FILES["filePhotos"];
将具有一个值数组.
Your $_FILES["filePhotos"];
will have an array of values.
阅读: http://php.net/manual/zh/features.file-upload.multiple.php
$_FILES["filePhotos"]["name"][0];
$_FILES["filePhotos"]["name"][1];
$_FILES["filePhotos"]["name"][2];
$_FILES["filePhotos"]["name"][3];
$_FILES["filePhotos"]["name"][4];
还请注意,有一个上传限制配置值. http://php.net/manual/zh/ini .core.php#ini.max-file-uploads
Also note that there is an upload limit config value.http://php.net/manual/en/ini.core.php#ini.max-file-uploads
默认为20.
这篇关于PHP:使用< input type ='file'>上传多张照片;同名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!