-4

我已经在服务器上完美上传了低于 70 kb 的图片。管理服务器 cpanel 视图已经设置 php.ini 文件 max_upload =2000mb max-exe-time = 300 max input time =600php.ini 文件一切正常。我的问题高于 70kb 图像无法移动临时目录
我无法理解我使用 zend 框架和 java 脚本使用

我的控制器代码

    public function changeImageProcessAction() {

    $this->_helper->layout->disableLayout();
    if ($this->getRequest()->isPost()) 
    {
        $file = $_FILES['file'];

        // DO NOT CHANGE BELOW
        $tempName = strtotime(date('Y-m-d H:i:s')); //$_SESSION["SESSION_TEMP_ARTIST_IMG_NAME"];
        $allowedImageTypes = explode(",", UPLOAD_ACCEPTED_MIME_TYPES);

        $fileSize = $file['size'];
        $fileType = $file['type'];
        $fileExt = strtolower(end(explode('.', $file['name'])));
        if (MAX_IMAGE_UPLOAD_SIZE< $fileSize) { // Check for Max File Size
            echo '{ "result" : "false",
                        "message"  : "The file is too big."}';              
        } else {
            if ($file['tmp_name'] != '') {  

                if (in_array($fileType, $allowedImageTypes)) {                      
                    $tempFile = SYSTEM_TEMP_DIRECTORY . "$tempName.$fileExt" ;
                    $session = new Zend_Session_Namespace(DEFAULT_SESSION_NAMESPACE);
                    $catID = $this->getRequest()->getPost('categoryID','');
                    if($catID == "")
                            $catID = $session->CURRENT_MAIN_CATEGORY_ID;

                    $imageLocation = MAIN_CATEGORY_IMAGE_PATH . "$catID.jpg";
                    // move file to the 'temp' folder
                    if (!file_exists($tempFile)) {
                        move_uploaded_file($file['tmp_name'],$tempFile);
                        if (file_exists($tempFile)) {   
                            list($width, $height) = getimagesize($tempFile);
                            if($width < IMAGE_CATEGORY_MAX_UPLOAD_WIDTH ||  $height < IMAGE_CATEGORY_MAX_UPLOAD_HEIGHT)
                            {
                                unlink($tempFile);
                                echo '{ "result" : "false",
                                        "message"  : "Invalid image dimensions."}'; 
                            }
                            else
                            {
                                $imageResult = Classes_ImageProcessor::cropImage($tempFile, $imageLocation, IMAGE_CATEGORY_IPHONE_WIDTH, IMAGE_CATEGORY_IPHONE_HEIGHT, $fileType);  

                                $imageLocation = MAIN_CATEGORY_IPAD_IMAGE_PATH . "$catID.jpg";
                                $imageResultIpad = Classes_ImageProcessor::cropImage($tempFile, $imageLocation, IMAGE_CATEGORY_IPAD_WIDTH, IMAGE_CATEGORY_IPAD_HEIGHT, $fileType);  

                                if($imageResult && $imageResultIpad )           
                                {
                                    $objCommon = new Classes_Common();
                                    $objCommon->setLastUpdatedTime("Image for category $catID is created");
                                    unlink($tempFile);
                                    $imagePath = LIVE_HOST_URL . MAIN_CATEGORY_IMAGE_PATH . $catID . '.jpg?' . time();
                                    echo '{"result" : "true", "name":"'.$file['name'].'", "type":"'.$file['type'].'", "size":"'.round($file['size']/1048576, 2).'Mb", "imagePath":"'."$imagePath".'", "newname":"'."$catID.jpg".'","message"  : "The image created successfully"}'; 
                                }
                                else
                                {
                                    unlink($tempFile);
                                    echo '{ "result" : "false",
                                        "message"  : "Image configuration failed"}';
                                }
                            }
                        } else {
                            echo '{ "result" : "false",
                                        "message"  : "Image saving failed"}';
                        }
                    } else {
                        echo '{ "result" : "false",
                                        "message"  : "The file already exists"}';
                    }
                } else {
                    echo '{ "result" : "false",
                                        "message"  : "File type not allowed"}';
                }
            }
            else
            {
                echo '{ "result" : "false",
                                        "message"  : "The image is too large for upload"}';
            }
        }

    }

 }

                my configuration file 



  define("COOKIE_LIFE", (3600 * 24 * 30));
    define("DATATABLES_RECORDS_PER_PAGE",10);
      define("SYSTEM_TEMP_DIRECTORY", "News/");
   define("DATE_DEFAULT_TIMEZONE", "Australia/Melbourne");


    / / Image uploader
define("MAX_IMAGE_UPLOAD_SIZE",10485760); // 10 MB
 define("UPLOAD_ACCEPTED_MIME_TYPES",  "image/pjpeg,image/jpeg,image/jpg,image/png,image/x-png,image/gif");
      define("UPLOAD_ACCEPTED_FILE_TYPES", "jpeg,jpg,png,gif");

   // Image Configurations
     // Categories
     define("MAIN_CATEGORY_IMAGE_PATH", "data/image/category/");
         define("MAIN_CATEGORY_IPAD_IMAGE_PATH", "data/image/category/ipad/");
            define("IMAGE_CATEGORY_MAX_UPLOAD_WIDTH",100);
      define("IMAGE_CATEGORY_MAX_UPLOAD_HEIGHT",100);
      define("IMAGE_CATEGORY_IPHONE_WIDTH",450);
        define("IMAGE_CATEGORY_IPHONE_HEIGHT",450);
       define("IMAGE_CATEGORY_IPAD_WIDTH",450);
          define("IMAGE_CATEGORY_IPAD_HEIGHT",450);

           // Products
         define("PRODUCT_IMAGE_THUMB_PATH", "data/image/product/thumb/");
       define("PRODUCT_IMAGE_GALLERY_IPHONE", "data/image/product/gallery/iphone/");
          define("PRODUCT_IMAGE_GALLERY_IPAD", "data/image/product/gallery/ipad/");
         define("PRODUCT_IMAGE_IPHONE", "data/image/product/iphone/");
         define("PRODUCT_IMAGE_IPAD", "data/image/product/ipad/");
           define("CAMPAIGN_IMAGE_PATH", "data/image/campaign/");
       define("IMAGE_PRODUCT_MAX_UPLOAD_WIDTH",100);
      define("IMAGE_PRODUCT_MAX_UPLOAD_HEIGHT",100);
         define("IMAGE_PRODUCT_IPAD_LARGE_WIDTH",400);
        define("IMAGE_PRODUCT_IPAD_LARGE_HEIGHT",400);
           define("IMAGE_PRODUCT_IPHONE_LARGE_WIDTH",190);
        define("IMAGE_PRODUCT_IPHONE_LARGE_HEIGHT",190);
          define("IMAGE_PRODUCT_THUMB_WIDTH",250);
          define("IMAGE_PRODUCT_THUMB_HEIGHT",250);
        define("IMAGE_PRODUCT_IPAD_IMG_GALARY_THUMB_WIDTH",213);
       define("IMAGE_PRODUCT_IPAD_IMG_GALARY_THUMB_HEIGHT",196);
      define("IMAGE_PRODUCT_IPHONE_IMG_GALARY_THUMB_WIDTH",90);
      define("IMAGE_PRODUCT_IPHONE_IMG_GALARY_THUMB_HEIGHT",90);
      define("IMAGE_CAMPAIGN_MAX_UPLOAD_WIDTH",100);
      define("IMAGE_CAMPAIGN_MAX_UPLOAD_HEIGHT",100);
          define("IMAGE_CAMPAIGN_THUMB_WIDTH",90);
            define("IMAGE_CAMPAIGN_THUMB_HEIGHT",90);

         define("IMAGE_CAMPAIGN_IPHONE_WIDTH",320);
         define("IMAGE_CAMPAIGN_IPHONE_HEIGHT",196);

       define("IMAGE_CAMPAIGN_IPAD_WIDTH",768);
       define("IMAGE_CAMPAIGN_IPAD_HEIGHT",578);

        //video
      define("VIDEO_IMAGE_GALLERY_IPHONE", "data/image/video/iphone/");
        define("VIDEO_IMAGE_GALLERY_IPAD", "data/image/video/ipad/");
       define("IMAGE_VIDEO_IPAD_IMG_GALARY_THUMB_WIDTH",213);
        define("IMAGE_VIDEO_IPAD_IMG_GALARY_THUMB_HEIGHT",196);
         define("IMAGE_VIDEO_IPHONE_IMG_GALARY_THUMB_WIDTH",90);
        define("IMAGE_VIDEO_IPHONE_IMG_GALARY_THUMB_HEIGHT",90);

       // Message Colors
           define("MSG_COLOR_SUCCESS", "#3C7B11");
           define("MSG_COLOR_FAILED", "#FF8000");
       define("MSG_COLOR_ERROR", "#F00");

    // SQL
       define("SQL_DATE_PATTERN", "yyyy-MM-dd HH:mm:ss");

     // Customer
      define("CUSTOMER_ENCRYPTION_KEY", "ENGETTD@@33");
        define("CUSTOMER_IMAGE_THUMB_PATH", "data/image/profile/");
      define("IMAGE_CUSTOMER_MAX_UPLOAD_WIDTH",0);
      define("IMAGE_CUSTOMER_MAX_UPLOAD_HEIGHT",0);
     define("IMAGE_CUSTOMER_THUMB_WIDTH",125);
      define("IMAGE_CUSTOMER_THUMB_HEIGHT",125);

     // Push Notification
        define("APN_HOST","ssl://gateway.push.apple.com");
         define("APN_PORT","2195");
      define("APN_CERTIFICATE_FILE","ck.pem");
4

1 回答 1

2

您的代码中似乎定义了一个常量“MAX_IMAGE_UPLOAD_SIZE”。如果 img 大小超过该值,它会回显“...文件太大”。

您只需要在代码中找到定义 MAX_IMAGE_UPLOAD_SIZE 的位置。它可能在一些随附的配置文件中,或者在您上面摘录的脚本中包含(或需要)的一些其他文件中。

于 2013-06-20T06:26:34.170 回答