0

我有这个代码,我需要在文件夹 images/app 中复制两个图像“原始”和“tmp_image”。

我怎样才能移动这些图片?:

我试过这个,但只移动图片“原始”:

move_uploaded_file("images/app/".$_FILES["imagen"]["tmp_name"],"images/app/".$_FILES["imagen"]["name"]);

 function resize($target,$new,$w,$h,$type){
   list($wo,$ho)=getimagesize($target);
    if($type=="image/jpeg"){
     $nen = imagecreatefromjpeg($target);
    }elseif($type=="image/gif"){
     $nen = imagecreatefromgif($target);
    }elseif($type=="image/png"){
     $nen = imagecreatefrompng($target);
    }
      $chen = imagecreatetruecolor($w,$h);
      imagecopyresampled($chen,$nen,0,0,0,0,$w,$h,$wo,$ho);
      imagejpeg($chen,$new,80);
                                         }

move_uploaded_file($_FILES["imagen"]["tmp_name"],$_FILES["imagen"]["name"]);
    $meter = "http://server/prueba/images/app/" . $_FILES["imagen"]["name"];
    $target = $_FILES["imagen"]["name"];
    $ssql = "insert into ofertas (imagen) values ('" . $meter . "')";
            $new = "resize_".$target;
            $type = $_FILES['imagen']['type'];
            $w = 80;
            $h = 80;
            resize($target,$new,$w,$h,$type);

谢谢大家!!

4

1 回答 1

0

您对问题的解释有点难以理解。如果我猜对了,下面就是答案。

如果您将上传的文件移动到新位置然后调整它的大小 - 它会被覆盖。尝试更改目标名称并将文件复制到目标名称。例如

$target = $_FILES["imagen"]["name"];

改成

 $target = 'thumb_'.$_FILES["imagen"]["name"];
于 2013-10-08T13:01:29.933 回答