Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help with Advance Image upload & Resizing 1

Status
Not open for further replies.

WilliamMute007

Programmer
Sep 30, 2007
116
GB
Hi All,

I have a script which basically uploades an image to folder (unique folder) each time.

I wanted to extend this script so that when it uploads the image, it should ALSO create a small thumbnail of it so I'll have the original and a small version. I want to store the two images in the same folder with the smaller one simply having "small" or something of that nature appended to the end of the original file name so I can distinguish the two.

The main script works perfectly but I have been having problems for over a day now with the resizing. Please see if you can help... Script below


Code:
<?
include('verify.php');


$title = $_POST['title'];
$text = $_POST['text'];
$categorie = $_POST['categorie'];
$categorie_name = $_POST['categorie_name'];
$author = $_POST['author'];

// Call for the name of categorie
$queryd = "SELECT * FROM $table_d WHERE id_cat=$categorie"; 
$resultd = mysql_query($queryd);
$mycat = @mysql_fetch_object($resultd);
$categorie_name = $mycat->categorie_name;

// LAST INCREMENTATION
$queryz = "SELECT last FROM $table_g"; 
$resultz = mysql_query($queryz);
$incr = @mysql_fetch_object($resultz);
$nrowss = $incr->last;

// NEW ID
$id= $nrowss+1;

umask(0000);
mkdir('../appreciateduploads/'.$id.'', 0777);
	// Folder blog + id of the new article
	$uploadDir = '../appreciateduploads/'.$id.'/';
	
	// Image file data
	$fileName = $_FILES['preview']['name'];
	$tmpName  = $_FILES['preview']['tmp_name'];

    // File extension extraction
	$ext = substr(strrchr($fileName, "."), 1);
	
	// File extension verification
	if ($ext != "jpg" ) { 
		echo ("Only jpg file are accepted (extension .jpg) Thanks !");
		exit;
		}

		
	// Generate random name
	$randName = md5(rand() * time());
	
	// Creation of path
    $filePath = $uploadDir . $fileName;
    $newfilename = $fileName;




list($width,$height)=getimagesize($tmpName, $filePath);
$newwidth=60;
$newheight=($height/$width)*$newwidth;
$tmp=imagecreatetruecolor($newwidth,$newheight);

$newwidth1=150; //This is where I set the width of the thumbnail
$newheight1=($height/$width)*$newwidth1;
$tmp1=imagecreatetruecolor($newwidth1,$newheight1);

imagecopyresampled($tmp,$src,0,0,0,0,$newwidth,$newheight,

 $width,$height);

imagecopyresampled($tmp1,$src,0,0,0,0,$newwidth1,$newheight1, 

$width,$height);


$filename = "../"$filePath"/". $_FILES['preview']['name'];
$filename1 = "../"$filePath"small". $_FILES['preview']['name'];


//$filename = "upload/". $_FILES['file']['name']; //This is where I decide where to store the original image.  Same size as the thumb
$filename1 = ($tmpName,$filePath ["small"]);
//imagejpeg($tmp,$filename,100);
imagejpeg($tmpName,$filename1,100);
		





    // UPLOAD IMAGE
	// If something wrong.... we stop ! or we upload.
    $result    = move_uploaded_file($tmpName, $filename1, $filePath);
	if (!$result) {
		echo "Error during upload... Please try again or request assistant.";
		exit;
	}







$date_post	=	date("Y-m-d H:i:s");

$insert = mysql_query("INSERT INTO $table_b 
                       (
					   title,
					   text,
					   preview,
					   categorie,
					   categorie_name,
					   author,
					   date_post
					   )
					   VALUES
					   (
					   '$title',
					   '$text',
					   '$newfilename',
					   '$categorie',
					   '$categorie_name',
					   '$author',
					   '$date_post'
					   )") or die(mysql_error()); 
if(!$insert) echo alert("Error during insert...");

$update = mysql_query("UPDATE $table_g SET last='$id'");

if(!$update) echo alert("Error during update...");

header("location:update_rss.php");
?>


I appreciate your help in advance please.

Thank you
 
Code:
list($width,$height)=getimagesize($tmpName, $filePath);
getimagesize() takes only one argument. the $tmpName variable already holds the absolute path to the file.

these lines
Code:
$filename = "../"$filePath"/". $_FILES['preview']['name'];
$filename1 = "../"$filePath"small". $_FILES['preview']['name'];
do not work. you need to use the concatenator (dot) to join strings with variables.

Code:
$filename = "../" . $filePath . "/". $_FILES['preview']['name'];
$filename1 = "../" . $filePath . "small". $_FILES['preview']['name'];

this line does not work
Code:
imagejpeg($tmpName,$filename1,100);
because you are referencing a file uri in the first argument whereas you should be referencing the GD object. I suspect you want $tmp1.

 
Hi Justin,

Thanks for pointing those out. I implemented your suggestions now I get the following error:


"Warning: mkdir() [function.mkdir]: File exists in /home/fhlinux132/m/mmakers.co.uk/user/htdocs/Template/PHP_/CMS/works_add_process_new.php on line 27
Only jpg file are accepted (extension .jpg) Thanks !"



Here is what the code now looks like

Code:
<?
include('verify.php');


$title = $_POST['title'];
$text = $_POST['text'];
$categorie = $_POST['categorie'];
$categorie_name = $_POST['categorie_name'];
$author = $_POST['author'];

// Call for the name of categorie
$queryd = "SELECT * FROM $table_d WHERE id_cat=$categorie"; 
$resultd = mysql_query($queryd);
$mycat = @mysql_fetch_object($resultd);
$categorie_name = $mycat->categorie_name;

// LAST INCREMENTATION
$queryz = "SELECT last FROM $table_g"; 
$resultz = mysql_query($queryz);
$incr = @mysql_fetch_object($resultz);
$nrowss = $incr->last;

// NEW ID
$id= $nrowss+1;

umask(0000);
mkdir('../appreciateduploads/'.$id.'', 0777);
    // Folder blog + id of the new article
    $uploadDir = '../appreciateduploads/'.$id.'/';
    
    // Image file data
    $fileName = $_FILES['preview']['name'];
    $tmpName  = $_FILES['preview']['tmp_name'];

    // File extension extraction
    $ext = substr(strrchr($fileName, "."), 1);
    
    // File extension verification
    if ($ext != "jpg" ) { 
        echo ("Only jpg file are accepted (extension .jpg) Thanks !");
        exit;
        }

        
    // Generate random name
    $randName = md5(rand() * time());
    
    // Creation of path
    $filePath = $uploadDir . $fileName;
    $newfilename = $fileName;




list($width,$height)=getimagesize($tmpName);
$newwidth=60;
$newheight=($height/$width)*$newwidth;
$tmp=imagecreatetruecolor($newwidth,$newheight);

$newwidth1=150; //This is where I set the width of the thumbnail
$newheight1=($height/$width)*$newwidth1;
$tmp1=imagecreatetruecolor($newwidth1,$newheight1);

imagecopyresampled($tmp,$src,0,0,0,0,$newwidth,$newheight,

 $width,$height);

imagecopyresampled($tmp1,$src,0,0,0,0,$newwidth1,$newheight1, 

$width,$height);


$filename = "../" . $filePath . "/". $_FILES['preview']['name'];
$filename1 = "../" . $filePath . "small". $_FILES['preview']['name'];

//$filename = "upload/". $_FILES['file']['name']; //This is where I decide where to store the original image.  Same size as the thumb

$filename1 = ($tmpName);
//$filename1 = ($tmpName,$filePath ["small"]);
//imagejpeg($tmp,$filename,100);
imagejpeg($tmp1,$filename1,100);
        





    // UPLOAD IMAGE
    // If something wrong.... we stop ! or we upload.
    $result    = move_uploaded_file($tmpName, $filename1, $filePath);
    if (!$result) {
        echo "Error during upload... Please try again or request assistant.";
        exit;
    }







$date_post    =    date("Y-m-d H:i:s");

$insert = mysql_query("INSERT INTO $table_b 
                       (
                       title,
                       text,
                       preview,
                       categorie,
                       categorie_name,
                       author,
                       date_post
                       )
                       VALUES
                       (
                       '$title',
                       '$text',
                       '$newfilename',
                       '$categorie',
                       '$categorie_name',
                       '$author',
                       '$date_post'
                       )") or die(mysql_error()); 
if(!$insert) echo alert("Error during insert...");

$update = mysql_query("UPDATE $table_g SET last='$id'");

if(!$update) echo alert("Error during update...");

header("location:update_rss.php");
?>

Thanks for your help in advance
 
hopefully this cleans your code up a bit and helps you see the pitfalls

Code:
<?php
	include('verify.php');
	//make sure that we actually have a file to work with
	if ($_FILES['preview']['error'] !== 0):
		exit('There was an error with the upload');
	endif;
	
	$title = $_POST['title'];
	$text = $_POST['text'];
	$categorie = $_POST['categorie'];
	$categorie_name = $_POST['categorie_name'];
	$author = $_POST['author'];
	
	// Call for the name of categorie
	$queryd = "SELECT * FROM $table_d WHERE id_cat=" . intval(mysql_real_escape_string($categorie)); 
	$resultd = mysql_query($queryd);
	$mycat = @mysql_fetch_object($resultd);
	$categorie_name = $mycat->categorie_name;
	
	// LAST INCREMENTATION
	$queryz = "SELECT last FROM $table_g"; 
	$resultz = mysql_query($queryz);
	$incr = @mysql_fetch_object($resultz);
	$nrowss = intval($incr->last);
	
	// NEW ID
	
	$id= $nrowss++;
	
	//make sure that we are looking at a fresh directory
	while (is_dir('../appreciateduploads/'.$id)):
		$id++;
	endwhile;
	
	//get the proper path of the directory
	$uploadDir = realpath('../appreciateduploads');
	$uploadDir .= DIRECTORY_SEPARATOR . $id;
	
	//create directory
	$u = umask(0000);
	mkdir($uploadDir, 0777);
    
	//reset umask
	umask($u);
	
    // Image file data
    $fileName = $_FILES['preview']['name'];
    $tmpName  = $_FILES['preview']['tmp_name'];
    
    // Creation of path
    $preview = $newFileName = $uploadDir . DIRECTORY_SEPARATOR . $fileName;
  	
	//get information about the image

	list($width,$height, $type)=getimagesize($tmpName);
	
	switch ($type):
		//support png and jpeg
		CASE 'IMAGETYPE_JPEG':
		CASE 'IMAGETYPE_PNG':
			$thumb = makeThumbnail($tmpName, 60);
			if ($thumb):
				move_uploaded_file($tmpName, $fileName);
				rename($thumb, $uploadDir . DIRECTORY_SEPARATOR . 'thumb_' . $fileName);
				//clear up if necessary
				if (is_file($thumb)):
					unlink($thumb);
				endif;
				
				//update the database
				$date_post    =    date("Y-m-d H:i:s");
				//create an array for easy manipulation
				$data = compact ('title','text','preview','categorie','categorie_name','author','date_post');
				$data = array_map('mysql_real_escape_string', $data);
				$query = "Insert into $table_b (" . implode(',', array_keys($data)) . ") VALUES ('".implode(','.array_values($data)) . "')";
				mysql_query($query) or die('Cannot insert table data ' . mysql_error());
				
				//update the counter
				mysql_query("UPDATE $table_g SET last='$id'") or die('Cannot update counter ' . mysql_error());
				
				//redirect
				header("location:update_rss.php");
				exit;
			else:
				exit('error in creating thumbnail');
			endif;
		break;
		default:
			exit('File type is not supported');
	endswitch;		

function makeThumbnail($image, $width){
	if (!is_file($image)) return false;
	list($oldwidth, $oldheight, $type) = getimagesize($image);
	$nH = ($width/$oldwidth) * $oldheight;
	
	//get image type and create some variable functions
	list($a, $suffix) = explode('_', $type);
	$cF = 'imagecreatefrom'.$suffix;
	$sF = 'image'.$suffix;
	$qM = $suffix == 'JPEG' ? 100 : 9;
	
	//instantiate image
	$img = $cF($image);
	
	//instantiate new image
	$nImg = imagecreatetruecolor($width, $height);
	//resize image
	imagecopyresampled($nImg, $img, 0,0,0,0,0,0,$oldWidth, $oldHeight);
	imagedestroy($img);
	$fN = sys_get_temp_dir() . DIRECTORY_SEPARATOR . uniqid('image_'. true) . '.' . strtolower($suffix);
	$result = $sF($img, $fN, $qM);
	imagedestroy($nImg);
	return $result ? $fN : false;
}
?>
 
Thanks Justin, I now get this error "There was an error with the upload"

The funny thing also is, I even reversed back to the original code without thumbnail, even that has stopped working too :(

Don't know what is going on.

 
Please ignore my last comment as I spotted the obvious mistake on my side which was the cause. Now am getting an error

"File type is not supported"

Any hope of spotting the cause?

Thanks a bunch!
 
ok

please add this line
Code:
$type = constant($type);
after the list() lines at lines 55 and 95
 
Got this:

"Warning: constant() [function.constant]: Couldn't find constant 2 in /home/fhlinux132/m/mmakers.co.uk/user/htdocs/Template/PHP_/CMS/blog_add_process_new.php on line 56
File type is not supported
 
my apologies, i made assumptions without checking them.

be back in a minute
 
Code:
<?php
	include('verify.php');
	//make sure that we actually have a file to work with
	if ($_FILES['preview']['error'] !== 0):
		exit('There was an error with the upload');
	endif;
	
	$title = $_POST['title'];
	$text = $_POST['text'];
	$categorie = $_POST['categorie'];
	$categorie_name = $_POST['categorie_name'];
	$author = $_POST['author'];
	
	// Call for the name of categorie
	$queryd = "SELECT * FROM $table_d WHERE id_cat=" . intval(mysql_real_escape_string($categorie)); 
	$resultd = mysql_query($queryd);
	$mycat = @mysql_fetch_object($resultd);
	$categorie_name = $mycat->categorie_name;
	
	// LAST INCREMENTATION
	$queryz = "SELECT last FROM $table_g"; 
	$resultz = mysql_query($queryz);
	$incr = @mysql_fetch_object($resultz);
	$nrowss = intval($incr->last);
	
	// NEW ID
	
	$id= $nrowss++;
	
	//make sure that we are looking at a fresh directory
	while (is_dir('../appreciateduploads/'.$id)):
		$id++;
	endwhile;
	
	//get the proper path of the directory
	$uploadDir = realpath('../appreciateduploads');
	$uploadDir .= DIRECTORY_SEPARATOR . $id;
	
	//create directory
	$u = umask(0000);
	mkdir($uploadDir, 0777);
    
	//reset umask
	umask($u);
	
    // Image file data
    $fileName = $_FILES['preview']['name'];
    $tmpName  = $_FILES['preview']['tmp_name'];
    
    // Creation of path
    $preview = $newFileName = $uploadDir . DIRECTORY_SEPARATOR . $fileName;
  	
	//get information about the image

	list($width,$height, $type)=getimagesize($tmpName);
	$type = constant($type);
	switch ($type):
		//support png and jpeg
		CASE IMAGETYPE_JPEG:
		CASE IMAGETYPE_PNG:
			$thumb = makeThumbnail($tmpName, 60);
			if ($thumb):
				move_uploaded_file($tmpName, $fileName);
				rename($thumb, $uploadDir . DIRECTORY_SEPARATOR . 'thumb_' . $fileName);
				//clear up if necessary
				if (is_file($thumb)):
					unlink($thumb);
				endif;
				
				//update the database
				$date_post    =    date("Y-m-d H:i:s");
				//create an array for easy manipulation
				$data = compact ('title','text','preview','categorie','categorie_name','author','date_post');
				$data = array_map('mysql_real_escape_string', $data);
				$query = "Insert into $table_b (" . implode(',', array_keys($data)) . ") VALUES ('".implode(','.array_values($data)) . "')";
				mysql_query($query) or die('Cannot insert table data ' . mysql_error());
				
				//update the counter
				mysql_query("UPDATE $table_g SET last='$id'") or die('Cannot update counter ' . mysql_error());
				
				//redirect
				header("location:update_rss.php");
				exit;
			else:
				exit('error in creating thumbnail');
			endif;
		break;
		default:
			exit('File type is not supported');
	endswitch;		

function makeThumbnail($image, $width){
	if (!is_file($image)) return false;
	list($oldwidth, $oldheight, $type) = getimagesize($image);
	$suffix = strtolower(image_type_to_extension($type));
	$nH = ($width/$oldwidth) * $oldheight;
	
	//get image type and create some variable functions
	$cF = 'imagecreatefrom'.$suffix;
	$sF = 'image'.$suffix;
	$qM = $suffix == 'jpeg' ? 100 : 9;
	
	//instantiate image
	$img = $cF($image);
	
	//instantiate new image
	$nImg = imagecreatetruecolor($width, $height);
	//resize image
	imagecopyresampled($nImg, $img, 0,0,0,0,0,0,$oldWidth, $oldHeight);
	imagedestroy($img);
	$fN = sys_get_temp_dir() . DIRECTORY_SEPARATOR . uniqid('image_'. true) . '.' . $suffix;
	$result = $sF($img, $fN, $qM);
	imagedestroy($nImg);
	return $result ? $fN : false;
}
?>
 
No Luck Sir, Getting this error:


Warning: constant() [function.constant]: Couldn't find constant 2 in /home/fhlinux132/m/mmakers.co.uk/user/htdocs/Template/PHP_/CMS/blog_add_process_new.php on line 56
File type is not supported
 
i forgot to delete that line.

please delete the line
Code:
$type = constant($type);
 
Deleted it, now getting:

Fatal error: Call to undefined function imagecreatefrom.jpeg() in /home/fhlinux132/m/mmakers.co.uk/user/htdocs/Template/PHP_/CMS/blog_add_process_new.php on line 103
 
bum bum bum. doing too much at once

Code:
<?php
	include('verify.php');
	//make sure that we actually have a file to work with
	if ($_FILES['preview']['error'] !== 0):
		exit('There was an error with the upload');
	endif;
	
	$title = $_POST['title'];
	$text = $_POST['text'];
	$categorie = $_POST['categorie'];
	$categorie_name = $_POST['categorie_name'];
	$author = $_POST['author'];
	
	// Call for the name of categorie
	$queryd = "SELECT * FROM $table_d WHERE id_cat=" . intval(mysql_real_escape_string($categorie)); 
	$resultd = mysql_query($queryd);
	$mycat = @mysql_fetch_object($resultd);
	$categorie_name = $mycat->categorie_name;
	
	// LAST INCREMENTATION
	$queryz = "SELECT last FROM $table_g"; 
	$resultz = mysql_query($queryz);
	$incr = @mysql_fetch_object($resultz);
	$nrowss = intval($incr->last);
	
	// NEW ID
	
	$id= $nrowss++;
	
	//make sure that we are looking at a fresh directory
	while (is_dir('../appreciateduploads/'.$id)):
		$id++;
	endwhile;
	
	//get the proper path of the directory
	$uploadDir = realpath('../appreciateduploads');
	$uploadDir .= DIRECTORY_SEPARATOR . $id;
	
	//create directory
	$u = umask(0000);
	mkdir($uploadDir, 0777);
    
	//reset umask
	umask($u);
	
    // Image file data
    $fileName = $_FILES['preview']['name'];
    $tmpName  = $_FILES['preview']['tmp_name'];
    
    // Creation of path
    $preview = $newFileName = $uploadDir . DIRECTORY_SEPARATOR . $fileName;
  	
	//get information about the image

	list($width,$height, $type)=getimagesize($tmpName);
	switch ($type):
		//support png and jpeg
		CASE IMAGETYPE_JPEG:
		CASE IMAGETYPE_PNG:
			$thumb = makeThumbnail($tmpName, 60);
			if ($thumb):
				move_uploaded_file($tmpName, $fileName);
				rename($thumb, $uploadDir . DIRECTORY_SEPARATOR . 'thumb_' . $fileName);
				//clear up if necessary
				if (is_file($thumb)):
					unlink($thumb);
				endif;
				
				//update the database
				$date_post    =    date("Y-m-d H:i:s");
				//create an array for easy manipulation
				$data = compact ('title','text','preview','categorie','categorie_name','author','date_post');
				$data = array_map('mysql_real_escape_string', $data);
				$query = "Insert into $table_b (" . implode(',', array_keys($data)) . ") VALUES ('".implode(','.array_values($data)) . "')";
				mysql_query($query) or die('Cannot insert table data ' . mysql_error());
				
				//update the counter
				mysql_query("UPDATE $table_g SET last='$id'") or die('Cannot update counter ' . mysql_error());
				
				//redirect
				header("location:update_rss.php");
				exit;
			else:
				exit('error in creating thumbnail');
			endif;
		break;
		default:
			exit('File type is not supported');
	endswitch;		

function makeThumbnail($image, $width){
	if (!is_file($image)) return false;
	list($oldwidth, $oldheight, $type) = getimagesize($image);
	$suffix = strtolower(image_type_to_extension($type, false));
	$nH = ($width/$oldwidth) * $oldheight;
	
	//get image type and create some variable functions
	$cF = 'imagecreatefrom'.$suffix;
	$sF = 'image'.$suffix;
	$qM = $suffix == 'jpeg' ? 100 : 9;
	
	//instantiate image
	$img = $cF($image);
	
	//instantiate new image
	$nImg = imagecreatetruecolor($width, $height);
	//resize image
	imagecopyresampled($nImg, $img, 0,0,0,0,0,0,$oldWidth, $oldHeight);
	imagedestroy($img);
	$fN = sys_get_temp_dir() . DIRECTORY_SEPARATOR . uniqid('image_'. true) . '.' . $suffix;
	$result = $sF($img, $fN, $qM);
	imagedestroy($nImg);
	return $result ? $fN : false;
}
?>
 
lol... I guess thats what makes a genius :) Back to the work, Tried your refined code above and got this:


Warning: imagecreatetruecolor() [function.imagecreatetruecolor]: Invalid image dimensions in /home/fhlinux132/m/mmakers.co.uk/user/htdocs/Template/PHP_/CMS/blog_add_process_new.php on line 106

Warning: imagecopyresampled(): supplied argument is not a valid Image resource in /home/fhlinux132/m/mmakers.co.uk/user/htdocs/Template/PHP_/CMS/blog_add_process_new.php on line 108

Warning: imagejpeg(): 13 is not a valid Image resource in /home/fhlinux132/m/mmakers.co.uk/user/htdocs/Template/PHP_/CMS/blog_add_process_new.php on line 111

Warning: imagedestroy(): supplied argument is not a valid Image resource in /home/fhlinux132/m/mmakers.co.uk/user/htdocs/Template/PHP_/CMS/blog_add_process_new.php on line 112
error in creating thumbnail
 
ok. so this means that the uploaded file is not correct for some reason.

substitute this function to get some debug info

Code:
function makeThumbnail($image, $width){
	if (!is_file($image)) return false;
	$info = getimagesize($image);
	print_r($info);
	list($oldwidth, $oldheight, $type) = $info; 
	$suffix = strtolower(image_type_to_extension($type, false));
	$nH = ($width/$oldwidth) * $oldheight;
	
	//get image type and create some variable functions
	$cF = 'imagecreatefrom'.$suffix;
	$sF = 'image'.$suffix;
	$qM = $suffix == 'jpeg' ? 100 : 9;
	
	//instantiate image
	$img = $cF($image);
	
	//instantiate new image
	$nImg = imagecreatetruecolor($width, $height);
	//resize image
	imagecopyresampled($nImg, $img, 0,0,0,0,0,0,$oldWidth, $oldHeight);
	imagedestroy($img);
	$fN = sys_get_temp_dir() . DIRECTORY_SEPARATOR . uniqid('image_'. true) . '.' . $suffix;
	$result = $sF($img, $fN, $qM);
	imagedestroy($nImg);
	return $result ? $fN : false;
}
 
Here is the Debug info Sir!

Array ( [0] => 1600 [1] => 1200 [2] => 2 [3] => width="1600" height="1200" [bits] => 8 [channels] => 3 [mime] => image/jpeg )
Warning: imagecreatetruecolor() [function.imagecreatetruecolor]: Invalid image dimensions in /home/fhlinux132/m/mmakers.co.uk/user/htdocs/Template/PHP_/CMS/blog_add_process_new.php on line 108

Warning: imagecopyresampled(): supplied argument is not a valid Image resource in /home/fhlinux132/m/mmakers.co.uk/user/htdocs/Template/PHP_/CMS/blog_add_process_new.php on line 110

Warning: imagejpeg(): 13 is not a valid Image resource in /home/fhlinux132/m/miraclemakers.co.uk/user/htdocs/Template/PHP_/CMS/blog_add_process_new.php on line 113

Warning: imagedestroy(): supplied argument is not a valid Image resource in /home/fhlinux132/m/mmakers.co.uk/user/htdocs/Template/PHP_/CMS/blog_add_process_new.php on line 114
error in creating thumbnail
 
you may be using an older version of the GD library that does not support non-integer widths.
i also note that i have misnamed a variable which will definitely have a negative effect

try changing the code as shown
Code:
[red]$height[/red] = [red]intval([/red]($width/$oldwidth) * $oldheight[red])[/red];
 
Thanks, I now have this error:

Array ( [0] => 1600 [1] => 1200 [2] => 2 [3] => width="1600" height="1200" [bits] => 8 [channels] => 3 [mime] => image/jpeg )
Warning: imagejpeg(): 13 is not a valid Image resource in /home/fhlinux132/m/mmakers.co.uk/user/htdocs/Template/PHP_/CMS/blog_add_process_new.php on line 114
error in creating thumbnail
 
this line
Code:
$result = $sF($img, $fN, $qM);

should be

Code:
$result = $sF($[red]nI[/red]mg, $fN, $qM);

really sorry about this. sloppy work. too fast and too many balls in the air.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top