getimagesize() 不返回图像值

getimagesize() not returning the image values

我正在尝试使用 getimagesize 函数。我正在使用 Dropzone.js 进行图片上传,我正在使用 codeigniter。

上传功能:

public function upload() //upload multiple images-dropzone

{ 
      if (!empty($_FILES)) {
        $tempFile = $_FILES['file']['tmp_name'];

    $fileName = str_replace(' ', '_', $_FILES["file"]["name"]);
    $file_name = substr(uniqid(rand()),0,10000).'_'.$fileName ;
        $targetPath = './uploads/';
        $targetFile = $targetPath . $file_name ;
        move_uploaded_file($tempFile, $targetFile);



    $this->thumb($targetFile,$targetPath,$file_name,$tempFile);     

}}

我的拇指功能:

function thumb($targetFile,$targetPath,$file_name,$tempFile)
{
    require_once('php_image_magician.php');

    $magicianObj = new imageLib($targetFile);

    list($width, $height, $type, $attr) = getimagesize($tempFile);  

    if($width = $height)
    {
    $magicianObj->resizeImage(150,150);
    }
    else if($width > $height)
    {
    $magicianObj->resizeImage(150,40);  
    }
    else
    {
    $magicianObj->resizeImage(40,150);  
    }


    // saving file to thumb directory
    $magicianObj->saveImage($targetPath . 'thumb/' . $file_name, 100);
}

在这种情况下,我尝试比较高度和宽度,但无法正常工作。它总是取第一个条件。

你已经使用了move_uploaded_file,所以之后$tempFile 将找不到,因为它已经被移动了,而是使用copy() 函数。