Jump to content


This topic is now archived and is closed to further replies.


Thumbnail generation problem

Recommended Posts

This is the code im am using
<form enctype="multipart/form-data" action="<?=$_SERVER['PHP_SELF']?>" method="POST">
<input type="hidden" name="MAX_FILE_SIZE" value="3000000">
Image:<br><input name="userfile" type="file"><br>
<input type="submit" name="upload" value="Upload">

$uploaddir = '/usr/home/pwncae/public_html/gallery/';
$uploadfile = $uploaddir . basename($_FILES['userfile']['name']);

if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) {
   echo "<br>File is valid, and was successfully uploaded.";

$im_file_name = $fullurl;
$image_attribs = getimagesize($im_file_name);
$im_old = imageCreateFromJpeg($im_file_name);
$th_max_width = 144;
$th_max_height = 144;
$ratio = ($width > $height) ? $th_max_width/$image_attribs[0] : $th_max_height/$image_attribs[1];
$th_width = $image_attribs[0] * $ratio;
$th_height = $image_attribs[1] * $ratio;
$im_new = imagecreatetruecolor($th_width,$th_height);
$th_file_name = '/gallery/thumbs/' . $_FILES['image_file']['name'];
imageCopyResampled($im_new,$im_old,0,0,0,0,$th_width,$th_height, $image_attribs[0], $image_attribs[1]);
imageJpeg($im_new,$im_file_name,100); }}

See below for the error

Share this post

Link to post
Share on other sites
File is valid, and was successfully uploaded.
Warning: imagejpeg(): Unable to open 'http://www.pwncaeks.com/gallery/thumbs/' for writing in /home/pwncae/public_html/dashboard/testgall2.php on line 34

sorry about the first post, the errors there arent what was actually going on, used to much bandwidth at once so it cut the image off, anyway, the above error is my problem

Share this post

Link to post
Share on other sites
Does the folder ..../gallery/thumbs actually exist? Does it have the correct permissions to allow you to save files to it?

Share this post

Link to post
Share on other sites


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.