mike12255 Posted March 15, 2009 Share Posted March 15, 2009 I have the following code: <?php ini_set ("display_errors", "1"); error_reporting(E_ALL); //this returns the name of the image $name = $_FILES['uploadfile']['name']; //get the extension of the image $ext = substr($name,-3); //We will add some secruity here, make sure the extension is an image file extension if($ext == "gif" || $ext == "jpg" || $ext == "png" || $ext == "peg"){ //The part the user selected to insert the image into $area = $_POST['catagory']; //more security, make sure 'catagory' is actually a choice offered and not a mysql query (or something else entered) if (!in_array($area, array("Sofas","Beds and Bunks","Dressers and Cabinets","Side Tables and Desks"))) { header ("Location: index.php"); } //set vars in here $wantedname = $_POST['name']; // This is the temporary file created by PHP $uploadedfile = $_FILES['uploadfile']['tmp_name']; //below changes the files name if ($name != $wantedname){ $name = $wantedname; } list($width,$height)=getimagesize($uploadedfile); $newwidth = 100; $newheight = 100; //copy the file to were we want it now //die($name); rename("$uploadedfile", "images/" . $area . "/". $name . $ext); //lets resize it now!! $path = "images/$area"."/". $name . "." . $ext; $src = imagecreatefromjpeg($path); list($width,$height)=getimagesize($path); $tmp=imagecreatetruecolor($newwidth,$newheight); imagecopyresampled($tmp,$src,0,0,0,0,$newwidth,$newheight,$width,$height); }else{ header ("Location: index.php"); } ?> and i had it working, but no for some reason it dosnt work i get these following errors: Warning: imagecreatefromjpeg(images/Sofas/noonewouldusethis.jpg) [function.imagecreatefromjpeg]: failed to open stream: No such file or directory in /home/schoolw1/public_html/kaon/upload.php on line 39 Warning: getimagesize(images/Sofas/noonewouldusethis.jpg) [function.getimagesize]: failed to open stream: No such file or directory in /home/schoolw1/public_html/kaon/upload.php on line 40 Warning: imagecopyresampled(): supplied argument is not a valid Image resource in /home/schoolw1/public_html/kaon/upload.php on line 42 Link to comment https://forums.phpfreaks.com/topic/149567-resizing-image/ Share on other sites More sharing options...
Daniel0 Posted March 16, 2009 Share Posted March 16, 2009 Well, read the error. The file doesn't exist. Link to comment https://forums.phpfreaks.com/topic/149567-resizing-image/#findComment-785651 Share on other sites More sharing options...
imperium2335 Posted March 16, 2009 Share Posted March 16, 2009 Maybe you need to make your paths relative/absolute, which ever fixes it. Link to comment https://forums.phpfreaks.com/topic/149567-resizing-image/#findComment-785667 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.