thepokematrix Posted August 26, 2008 Share Posted August 26, 2008 I had a script that as far as I know had been working, but anyway now the image fails to upload. The problem is with "imagejpeg()" toward the end of the script, but I don't know whats causing it to have an error. You might want to disregard some of the comments. Some of them are likely out of order. Heres my script: <? // Include MySQL class require_once('mysql.class.php'); // Include Database Nast require_once('dbinfo.php'); // Include functions require_once('functions.inc.php'); session_start(); if($_SESSION['auth']){ echo "<html><head><title>Add new Picture</title></head> <body><br><br>"; $title = $_REQUEST['title']; $category = $_REQUEST['category']; $price = $_REQUEST['price']; $description = $_REQUEST['description']; $img = $_FILES['uploadpic'] ['name']; // //resizeness $temporary_name = $_FILES['uploadpic']['tmp_name']; $mimetype = $_FILES['uploadpic']['type']; $filesize = $_FILES['uploadpic']['size']; switch($mimetype) { case "image/jpg": case "image/jpeg": $i = imagecreatefromjpeg($temporary_name); break; case "image/gif": $i = imagecreatefromgif($temporary_name); break; case "image/png": $i = imagecreatefrompng($temporary_name); break; } //deletes temp file unlink($temporary_name); // //adds info // mysql_connect ($host, $user, $password) or die ('I cannot connect to the database because: ' . mysql_error()); @mysql_select_db($database) or die( "Unable to select database"); //Finds the rank $query1="SELECT * FROM paintings WHERE category='$category'"; $result1=mysql_query($query1); $rank=mysql_numrows($result1);//The total number of pictures //uploads the pic //save full image $width=ImageSx($i); $height=ImageSy($i); $pic = imagecreatetruecolor($width,$height); //Copy the original image data to it using resampling imagecopyresampled($pic, $i ,0, 0, 0, 0, $width, $height, imagesx($i), imagesy($i)); //Save the Picture //THIS IS WHERE THE ERROR HAPPENS if(imagejpeg($pic, "$category/images/$rank.jpg", 100)){ } else { echo "Image failed to upload"; } Link to comment https://forums.phpfreaks.com/topic/121468-picture-upload-problem/ Share on other sites More sharing options...
DarkWater Posted August 26, 2008 Share Posted August 26, 2008 Okay, what does the error say? Link to comment https://forums.phpfreaks.com/topic/121468-picture-upload-problem/#findComment-626411 Share on other sites More sharing options...
thepokematrix Posted August 26, 2008 Author Share Posted August 26, 2008 Sorry I probably wasn't real clear. It doesn't actually give an error message. This part simply fails: if(imagejpeg($pic, "$category/images/$rank.jpg", 100)){ } So it just says "Image failed to upload" Link to comment https://forums.phpfreaks.com/topic/121468-picture-upload-problem/#findComment-626419 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.