[英]getimagesize() not returning the image values
I am trying to use getimagesize function. 我正在尝试使用getimagesize功能。 I am using Dropzone.js for image upload and I am using codeigniter. 我正在使用Dropzone.js进行图片上传,我正在使用codeigniter。
The upload function: 上传功能:
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);
}}
My thumb function: 我的拇指功能:
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);
}
In this condition I'm trying to compare the height and width but it's not working properly. 在这种情况下,我试图比较高度和宽度,但它不能正常工作。 It always takes the first condition. 它始终是第一个条件。
您已经使用了move_uploaded_file,因此在找到$ tempFile之后将找不到它,因为它已经被移动了,而是使用copy()函数。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.