ABOVE 70 kb IMAGE NOT UPLOAD in Temp Directory [cl

2019-09-22 03:09发布

I have upload below 70 kb image upload perfectly on server. manage server cpanel view already set php.ini file max_upload =2000mb max-exe-time = 300 max input time =600 php.ini file is everything ok. My problem above 70kb image can't move temp directory
i cant understand im using zend framework and java script using

my controller code

    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");

1条回答
混吃等死
2楼-- · 2019-09-22 03:25

There seems to be a constant "MAX_IMAGE_UPLOAD_SIZE" defined in your code. If the img size exceeds that, it echos "...the file is too big".

You just need to find the place in your code where MAX_IMAGE_UPLOAD_SIZE is defined. It may be in some accompanying configuration file, or some other file included (or required) by the script your excerpted above.

查看更多
登录 后发表回答