各位大神,麻烦帮小弟看一下,这段上传图片的代码,
我有十个选择图片的框,每次都只能上传五张图,在处理程序打印输出 ,记录也只是5。
诚心求教各大神指导!
index.php
<FORM enctype="multipart/form-data" name=form1 action=sp_add.php method=POST>
<p> </p>
<table border="1" width="1030" bordercolorlight="#000000" bordercolordark="#FFFFFF" style="border-collapse: collapse" cellpadding="2">
<tr>
<td width="100">商品图片1:</td>
<td width="257">
<input type="file" name="upfile[]" size="30" style="color: #000080; background-color: #EBEBEB"> </td>
<td width="90">商品图片6:</td>
<td width="301">
<input type="file" name="upfile[]" size="30" style="color: #000080; background-color: #EBEBEB"></td>
<td width="258">415*201像素</td>
</tr>
<tr>
<td width="100">商品图片2:</td>
<td width="257">
<input type="file" name="upfile[]" size="30" style="color: #000080; background-color: #EBEBEB"> </td>
<td width="90">商品图片7:</td>
<td width="301">
<input type="file" name="upfile[]" size="30" style="color: #000080; background-color: #EBEBEB"></td>
<td width="258">
415*201像素</td>
</tr>
<tr>
<td width="100">商品图片3:</td>
<td width="257">
<input type="file" name="upfile[]" size="30" style="color: #000080; background-color: #EBEBEB"> </td>
<td width="90">商品图片8:</td>
<td width="301">
<input type="file" name="upfile[]" size="30" style="color: #000080; background-color: #EBEBEB"></td>
<td width="258">
415*201像素</td>
</tr>
<tr>
<td width="100">商品图片4:</td>
<td width="257">
<input type="file" name="upfile[]" size="30" style="color: #000080; background-color: #EBEBEB"> </td>
<td width="90">商品图片9:</td>
<td width="301">
<input type="file" name="upfile[]" size="30" style="color: #000080; background-color: #EBEBEB"></td>
<td width="258">
415*201像素</td>
</tr>
<tr>
<td width="100">商品图片5:</td>
<td width="257">
<input type="file" name="upfile[]" size="30" style="color: #000080; background-color: #EBEBEB"> </td>
<td width="90">商品图片10:</td>
<td width="301">
<input type="file" name="upfile[]" size="30" style="color: #000080; background-color: #EBEBEB"></td>
<td width="258">
415*201像素</td>
</tr>
<tr>
<td width="100"> </td>
<td width="919" colspan="4"> </td>
</tr>
</table>
<p align="center">
<input type="submit" value="提交" name="submitfile" style="float: left"><input type="reset" value="重置" name="B2" style="float: left"> </p>
<input type="hidden" name="MAX_FILE_SIZE" value="200000000">
</form>
sp_add.php
<?
if ($_POST["submitfile"]!="")
{
$Path="../".date('Ym')."/";
if (!is_dir($Path))//创建路径
{ mkdir($Path); }
echo "<div>";
chmod($Path,0777);
echo count($_FILES["upfile"]); //这里打印输出,一直是5但是前面那个页面也没有问题
for ($i=0;$i<count($_FILES["upfile"]);$i++)
{
if ($_FILES["upfile"]["size"][$i]!=0)
{
$File=$Path.date('Ymdhm')."_".$_FILES["upfile"]["name"][$i];
if (move_uploaded_file($_FILES['upfile']['tmp_name'][$i],$File))
{
echo "文件上传成功 文件类型:".$_FILES["upfile"]["type"][$i]." "."文件名:".$_FILES["upfile"]["name"][$i]."<br>"; }
else
{ echo "文件名:".$_FILES["upfile"]["name"][$i]."上传失败</br>"; }
}
}
echo "</div><br><a href='$postadd' href='$postadd'>返回</a></div>";
}
?>