Jump to content

Upload problem


garydt

Recommended Posts

When I try to upload an image that is bigger than 2000 pixels wide i get server error 500. It does save the image on to the server. The error comes when it tries to resize the image. Here's the resize script-

	function resizeimage($name){
$filename = './uploads/'.$name;
	if(file_exists($filename)) {
		$image		= imagecreatefromjpeg($filename); //unresized image
		$im_info	= getimagesize($filename); //unresized image
		$im_width	= $im_info[0];
		$im_height	= $im_info[1];
		$im_flag	= $im_info[2];

		if($im_width >= $im_height) {
			$im_divice	= $im_width / 140;
		}else {
			$im_divice	= $im_height / 140;
		}
		$thumb_width	= $im_width / $im_divice;
		$thumb_height	= $im_height / $im_divice;

		//create empty image
		$thumb	= imagecreatetruecolor($thumb_width, $thumb_height);
		//resize image
		imagecopyresampled($thumb, $image, 0, 0, 0, 0, $thumb_width, $thumb_height, $im_width, $im_height);

		if(imagejpeg($thumb, "thumbnails/".$name, 80)) { //image-resource, filename, quality
			return 1;
		}

		imagedestroy($thumb); //destroy temporary image-resource
		imagedestroy($image); //destroy temporary image-resource
	}
}

Any ideas?

Link to comment
Share on other sites

Thanks. I've put-

<input type="hidden" name="MAX_FILE_SIZE" value="2000000000">

 

Tried uploading an image sized 1.95MB and 2150 pixels wide  but when i tried uploading an image sized 1.24MB and 2575 pixels wide i got server error.

That doesn't makes sense does it?

Link to comment
Share on other sites

I've got: -

 

;;;;;;;;;;;;;;;;

; File Uploads ;

;;;;;;;;;;;;;;;;

 

; Whether to allow HTTP file uploads.

file_uploads = On

 

; Temporary directory for HTTP uploaded files (will use system default if not

; specified).

;upload_tmp_dir =

 

; Maximum allowed size for uploaded files.

upload_max_filesize = 2M

 

...that's all I know about it sorry mate, I just read somewhere last time I was doing this that there was a similar entry in php.in. I was uploading docs not pics in a searchable knowledgebase type app.

 

Got all my answers from this site though so keep on at 'em!! They're good!

 

Mark

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.