php水印错误无法复制图像或放置水印

php水印错误无法复制图像或放置水印,php,image,upload,watermark,Php,Image,Upload,Watermark,经过长时间的截取代码并在我自己的多文件上传程序代码中的相应位置放置后,我遇到了一个错误,据我所知,没有任何原因,下面的代码就是我使用的 <?php ini_set("error_reporting", 1); if(isset($_POST['btnSubmit'])) { for ($i = 0; $i < count($_FILES['files']['name']); $i++) {

经过长时间的截取代码并在我自己的多文件上传程序代码中的相应位置放置后,我遇到了一个错误,据我所知,没有任何原因,下面的代码就是我使用的

<?php
    ini_set("error_reporting", 1);
    if(isset($_POST['btnSubmit']))
    {
        for ($i = 0; $i < count($_FILES['files']['name']); $i++)
        {
            if ($_FILES["files"]["size"][$i] < 1000000000) // Check File size (Allow 1000MB)
            {
                $temp = $_FILES["files"]["tmp_name"][$i];
                $name = $_FILES["files"]["name"][$i];
                $targetFilePath = 'images/thumbs/'.$name;
                $watermarkImagePath = 'watermark.png';
                $statusMsg = ''; 
                if(move_uploaded_file($_FILES["file"]["tmp_name"][$i], $targetFilePath)){ 
                // Load the stamp and the photo to apply the watermark to 
                $watermarkImg = imagecreatefrompng($watermarkImagePath); 
                switch($fileType){ 
                    case 'jpg': 
                        $im = imagecreatefromjpeg($targetFilePath); 
                        break; 
                    case 'jpeg': 
                        $im = imagecreatefromjpeg($targetFilePath); 
                        break; 
                    case 'png': 
                        $im = imagecreatefrompng($targetFilePath); 
                        break; 
                    default: 
                        $im = imagecreatefromjpeg($targetFilePath); 
                 } 
                }
                // Set the margins for the watermark 
                $marge_right = 10; 
                $marge_bottom = 10; 
                 
                // Get the height/width of the watermark image 
                $sx = imagesx($watermarkImg); 
                $sy = imagesy($watermarkImg); 
                 
                // Copy the watermark image onto our photo using the margin offsets and  
                // the photo width to calculate the positioning of the watermark. 
                imagecopy($im, $watermarkImg, imagesx($im) - $sx - $marge_right, imagesy($im) - $sy - $marge_bottom, 0, 0, imagesx($watermarkImg), imagesy($watermarkImg))>debug.log;
                 
                // Save image and free memory 
                imagepng($im, $targetFilePath); 
                
                $old = $targetFilePath;
                $new = "images/fulls/".$name;
                echo '<br/>img:'.$im.' <br/>target:'.$targetFilePath.' <br/>name:'.$name.' <br/>old:'.$old.' <br/>new:'.$new.'<br/>';
                copy($old, $new) or die("Unable to copy $old to $new.");
                imagedestroy($im); 
                
                if(file_exists($targetFilePath)){
                    $statusMsg = "The image with watermark has been uploaded successfully."; 
                }else{ 
                    $statusMsg = "Image upload failed, please try again."; 
                }
 // Display status message 
echo $statusMsg;
 
                if(empty($temp))
                {
                    break;
                }
                if($i == 0){ $err = "<span style='color:lime;'>Files uploaded successfully</span>"; $cls = "success"; }
                //move_uploaded_file($temp,"images/thumbs/".$name);
                //$old = "images/thumbs/".$name;
                //$new = "images/fulls/".$name;
                //copy($old, $new) or die("Unable to copy $old to $new.");
            }
            else
            {
                $err = "File size is more than 1000MB";
                $cls = "danger";
            }
        }
    }

?>

这可能是上载文件夹的权限问题,也可能是文件上载大小的限制。如代码所示,上载大小约为1000000或1000 mb。我尝试上载的图像大小约为1-25mb,产生相同的错误,但在我添加水印脚本之前,所有内容都可以在大小约为1 gig的池中上载毫无疑问,我只想在上传时添加水印,而不使用找到的完整代码id,因为该代码的大小由我在CPANELT上无法访问的php配置进行调节。请看一看。