0

我有点难过,因为我有一段运行循环的代码:

for($i=1; $i<=30; $i++) {
    if(!empty($_FILES['image_'.$i]['name'])) {
        copy($_FILES['image_'.$i]['tmp_name'], WEB_UPLOAD."/images/products/".$_FILES['image_'.$i]['name']) or die("Error uploading image.");
        $ext = strtolower(substr($_FILES['image_'.$i]['name'], strrpos($_FILES['image_'.$i]['name'], ".")));
        $image = "".text_to_url_image($name)."_product_".$i."_".$id."_large".$ext;
        $image_medium = "".text_to_url_image($name)."_product_".$i."_".$id."_medium".$ext;
        $image_small = "".text_to_url_image($name)."_product_".$i."_".$id."_small".$ext;

        rename(WEB_UPLOAD."/images/products/".$_FILES['image_'.$i]['name'], WEB_UPLOAD."/images/products/".$image); 

        $scale = '74x74';
        $go = WEB_UPLOAD.'/images/products/'.$image;
        $stop = WEB_UPLOAD.'/images/products/'.$image_small;
        exec("/usr/bin/convert $go -resize $scale\> -quality 100 $stop");
        unset($scale, $go, $stop);

        $scale = '158x158';
        $go = WEB_UPLOAD.'/images/products/'.$image;
        $stop = WEB_UPLOAD.'/images/products/'.$image_medium;
        exec("/usr/bin/convert $go -resize $scale\> -quality 100 $stop");
        unset($scale, $go, $stop);

        $scale = '620x500';
        $go = WEB_UPLOAD.'/images/products/'.$image;
        $stop = WEB_UPLOAD.'/images/products/'.$image;
        exec("/usr/bin/convert $go -resize $scale\> -quality 100 $stop");
        unset($scale, $go, $stop);

        chmod(WEB_UPLOAD."/images/products/".$image_small, 0777);
        chmod(WEB_UPLOAD."/images/products/".$image_medium, 0777);
        chmod(WEB_UPLOAD."/images/products/".$image, 0777);
        mysql_query("UPDATE `products` SET image_".$i."='".$image."' WHERE id='".$id."'");
    }
}

这适用于 image_1 到 image_15,但是当我尝试为 image_16 或更高版本上传图像时,它不会上传图像或将其输入到 SQL 中?表格如下所示:

for($i=1; $i<=30; $i++) {
    echo "<tr><td valign=\"top\">Gallery Image [".($i)."]:</td><td valign=\"top\">";
        echo "<input type=\"file\" name=\"image_".$i."\">";
        if(!empty($r['image_'.$i])) {
            echo "<br /><img src=\"".WEB_URL."/images/products/".$r['image_'.$i]."\" height=\"150\" />";
            echo "<a href=\"./?action=edit_products&id=".$id."&delete_image=image_".$i."\"><img src=\"images/delete.gif\"></a>";
        }
    echo "</td></tr>";
}

有任何想法吗?

谢谢,皮特

4

0 回答 0