franzwarning Posted March 20, 2011 Share Posted March 20, 2011 Hello, How could I resize the image to 320x480 before it is uploaded. Here is the code for the upload: <?php require("connect.php"); $query = mysql_query("SELECT * FROM items ORDER BY id DESC"); if (mysql_num_rows($query) > 0) { $row = mysql_fetch_assoc($query); $id = $row['id']; $id++; echo $id."<br>"; $username = $_GET['user']; $dateofupload = date("Y-m-d"); $uploaddir = './pqimages/'.$dateofupload.'/'; $file = basename($_FILES['userfile']['name']); $uploadfile = $uploaddir.$id.".jpg"; if (move_uploaded_file($_FILES['userfile']['tmp_name'],$uploadfile)){ echo "http://randomaydesigns.com/pqimages/{$file}"; $userid = mysql_query("SELECT * FROM users WHERE username ='$username'"); while ($row2 = mysql_fetch_assoc($userid)){ $userid = $row2['id']; $updateuserlastupload = mysql_query("UPDATE users SET lastupload='pqimages/".$dateofupload."/$id.jpg' WHERE username='$username'"); $updateuser = mysql_query("INSERT INTO items VALUES('','$userid','1','i','','','pqimages/".$dateofupload."/$id.jpg','0','a','$dateofupload')"); } } } ?> Cheers, GEORGE Quote Link to comment Share on other sites More sharing options...
exhaler Posted March 20, 2011 Share Posted March 20, 2011 you cannot resize an image before uploading it. in order for php to resize the image the image should be on the server. so upload the image then resize it. visit this website to resize images using php Quote Link to comment Share on other sites More sharing options...
perky416 Posted March 20, 2011 Share Posted March 20, 2011 You can find another good upload and resize script here: http://www.phpmagicbook.com/upload-image-and-create-thumbnail/ It also creates a thumbnail for you, however if you dont need it you can always remove that part of the code. 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.