I am trying to use getimagesize function. I am using Dropzone.js for image upload and I am using 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.