onlyican Posted September 25, 2006 Share Posted September 25, 2006 Hey guysSoz about the urgent, but it isi have a small static class to upload and resize imagesI am testing this live on the serverThis script allows for jpg, gifs, and pngsI can upload gifs and pngsbutjpeg is having some troubleThe snippit refering to resize and saving is [code]<?php function ResampleImage(){//$this->username is the users username,$this->file_ext is the file extension (jpg, gif, png) $new_file_name = $this->username.".".$this->file_ext; //$this->save_to is the directory $dir = $_SERVER['DOCUMENT_ROOT']."/".$this->save_to.$new_file_name; $image_p = imagecreatetruecolor($this->new_width, $this->new_height); switch($this->file_ext){ case "jpg": $image = imagecreatefromjpeg($_FILES["ufile"]["tmp_name"]); break; case "gif": $image = imagecreatefromgif($_FILES["ufile"]["tmp_name"]); break; case "png": $image = imagecreatefrompng($_FILES["ufile"]["tmp_name"]); break; } imagecopyresampled($image_p, $image, 0,0,0,0,$this->new_width, $this->new_height, $this->width, $this->height); $success_upload = false; switch($this->file_ext){ case "jpg": //This line is 147 if(imagejpeg($image_p, $dir)){ $success_upload = true; } break; case "gif": if(imagegif($image_p, $dir)){ $success_upload = true; } break; case "png": if(imagepng($image_p, $dir)){ $success_upload = true; } break; } imagedestroy($image_p); if($success_upload){ $this->allowed_upload = 1; }else{ $this->allowed_upload = 3; }?>[/code]The error is Warning: imagejpeg(): Unable to open '/home/onlyican/public_html/disabledfriends/friends/jamie.jpg' for writing in /home/onlyican/public_html/disabledfriends/inc/class_upload_img.php on line 147The chmod is 777Gifs and Pngs are working no probs, as u can see, the only difference between the image types is the function namelooking at the errorIts going to the right folderthe username and file extension is thereAny ideas Quote Link to comment Share on other sites More sharing options...
onlyican Posted September 25, 2006 Author Share Posted September 25, 2006 I also have the phps file uploadedhttp://onlyican.com/class_upload_img.phpsIf this helpsPlease help Quote Link to comment Share on other sites More sharing options...
onlyican Posted September 25, 2006 Author Share Posted September 25, 2006 Dont worry, I seemed to have solved the issueA friend of mine tested the function using a different userAs this is a remake to the siteI had an image online called jamie.jpgFor some reason it didn't want to overwrite itI renamed the already uploaded jamie.jpg to jamieX.jpgthen tried uploading and it workedthen I tried uploading again, testing the overwriting, to see if I need to do unlinkbut it workedso I am guessing that the oroiginal file was corrupt or something Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.