Jump to content

Resize and Image Before Upload


franzwarning

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/231206-resize-and-image-before-upload/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.