duangu4943 2015-06-20 00:13
浏览 20

尝试从允许更多输入的表单上传文件

I need to allow an admin to upload as many images as they like in their admin area. I am using a code that allows them to press a link and it adds another upload button. I then post it to a php script to upload the files. However, it's not uploading them, it's not even printing my error message. Any help would be great.

Here is a snip-it of the form code:

<tr>
<td width="280" bgcolor="#e1e1e1"><font color="#000000">Product Image:</font></td>
<td width="615" bgcolor="#e1e1e1">
<div id="newlink">
<div class="feed">
<input name="image[]" type="file" />
</div>
</div>
<p id="addnew">
<a href="javascript:add_feed()">Add Another Image </a>
</p>
<div id="newlinktpl" style="display:none">
<div class="feed">
<input name="image[]" type="file" />
</div>
</div>
</td></tr>

Here is the php code to upload the files:

$len = count($_POST['image']);
    for ($i=0; $i < $len; $i++)
    {
    $imagefile=$_POST['image'][$i];
        //if ($i == 0){$imgfile = $_POST['image'][$i];}
        //else {$imgfile = $imgfile."|".$_POST['image'][$i];}

$target2 = "../lp/companyuploads/images/";
$target2 = $target2 . basename( $_FILES[$imagefile]['name']) ;
 $ok=1; 
 # Limit file type condition 
 if ($uploaded_type =="text/php"){ 
 echo "No PHP files<br>"; 
 $ok=0; 
 } 
 # Check that $ok was not set to 0 by an error 
 if ($ok==0){ 
 Echo "Sorry your PDF file was not uploaded"; 
 } 
 # If everything is ok upload it 
 else {
 if(move_uploaded_file($_FILES[$imagefile]['tmp_name'], $target2)) {
 $name = basename( $_FILES[$imagefile]['name']) ; 
# Show success on screen
echo <<<END
<font size="+1" color="blue" face="Arial">$name has been uploaded successfully.</font>
END;
 } 
 else 
 { 
 echo "The ".$namefile." was not saved correctly, please let Randy know you got this error."; 
 } 
 }  
}
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥20 软件测试决策法疑问求解答
    • ¥15 win11 23H2删除推荐的项目,支持注册表等
    • ¥15 matlab 用yalmip搭建模型,cplex求解,线性化处理的方法
    • ¥15 qt6.6.3 基于百度云的语音识别 不会改
    • ¥15 关于#目标检测#的问题:大概就是类似后台自动检测某下架商品的库存,在他监测到该商品上架并且可以购买的瞬间点击立即购买下单
    • ¥15 神经网络怎么把隐含层变量融合到损失函数中?
    • ¥15 lingo18勾选global solver求解使用的算法
    • ¥15 全部备份安卓app数据包括密码,可以复制到另一手机上运行
    • ¥20 测距传感器数据手册i2c
    • ¥15 RPA正常跑,cmd输入cookies跑不出来