riceje7 Posted September 5, 2009 Share Posted September 5, 2009 i can't figure out why my thumbnail creation part of my script isn't working. can anyone see anything i'm doing wrong? code is line 55-73 <?php $username = $_POST['username']; $password = $_POST['password']; $password2 = $_POST['password2']; $email = $_POST['email']; $zip = $_POST['zip']; $image = $_FILES['image']; $imagename = $_FILES['image']['name']; $imagename = str_replace(' ', '_', $imagename); //echo $imagename; if($password != $password2) { echo "<center>Passwords do not match.</center>"; die; } //checking to see if users came from the registration page if(array_key_exists('submit', $_POST)) { //saving image //setting up mysql connection $connect = mysql_connect(localhost, $user, $pass); $db = mysql_select_db(user_data); //checking to see if username aready exists $sql = "SELECT * FROM user_data WHERE username='$username'"; $result = mysql_query($sql); $num = mysql_num_rows($result); //if it doesn't info is saved to the database if($num == 0) { //saving image $imageinfo = getimagesize($_FILES['image']['tmp_name']); if($imageinfo['mime'] != 'image/gif' && $imageinfo['mime'] != 'image/jpeg' && $imageinfo['mime'] != 'image/jpe' && $imageinfo['mime'] != 'image/jpg') { echo "<center>That is an invalid file type, you must upload either a JPEG or GIF file.<br/> Please use your browser's 'Back' button and try again.</center>"; exit; } $uploaddir = "user_images/"; $uploadfile = $uploaddir . basename($_FILES['image']['name']); if (move_uploaded_file($_FILES['image']['tmp_name'], $uploadfile)) { echo "<center>File Upload Successful</center>";} //////////////////////////thumbanail creation/////////////////////////////////////////// $n_width=100; // Fix the width of the thumb nail images $n_height=100; // Fix the height of the thumb nail imaage $tsrc="user_images/thumbs/".$_FILES[image][name]; // Path where thumb nail image will be stored //echo $tsrc; $im= imagecreatefromjpeg($uploadfile); $width=imagesx($im); // Original picture width is stored $height=imagesy($im); // Original picture height is stored //echo $width; //echo $height; $newimage=imagecreatetruecolor($n_width,$n_height); //echo $newimage; imagecopyresized($newimage,$im,0,0,0,0,$n_width,$n_height,$width,$height); imagejpeg($newimage,$tsrc); echo "<center>Thumbnail Creation Successful</center>"; /////////////////////end thumbanail creation////////////////////////////////////// //protecting from sql injections $username = stripslashes($username); $username = mysql_real_escape_string($username); $password = stripslashes($passowrd); $password = mysql_real_escape_string($password); $email = stripslashes($email); $email = mysql_real_escape_string($email); $zip = stripslashes($zip); $zip = mysql_real_escape_string($zip); $imagename = stripslashes($imagename); $imagename = mysql_real_escape_string($imagename); $password = md5($password); //inserting data $sql = "INSERT INTO `user_data`.`user_data` (`id`, `username`, `password`, `email`, `zipcode`, `picture_name`) VALUES (NULL, '$username', '$password', '$email','$zip', '$imagename');"; mysql_query($sql); echo "<center>Registration Successful</center>"; } else { echo "<center>Username Already Taken.</center>"; } } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <link REL="SHORTCUT ICON" HREF="favicon.ico"> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>Untitled Document</title> </head> <body onload="document.getElementById('username').focus();"> <table width="300" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC"> <tr> <form name="form1" method="post" action="process.php"> <td> <table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF"> <tr> <td colspan="3" align="center"><strong>Member Login </strong></td> </tr> <tr> <td width="78">Username</td> <td width="6">:</td> <td width="294"><input name="username" type="text" id="username"></td> </tr> <tr> <td>Password</td> <td>:</td> <td><input name="password" type="password" id="password"></td> </tr> <tr> <td> </td> <td> </td> <td align="right"><input type="submit" name="login" value="Login"></td> </tr> </table> </td> </form> </tr> </table> </body> </html> Link to comment https://forums.phpfreaks.com/topic/173270-solved-thumbnail-creation-not-working/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.