Reduce image dimensions on upload with php
I've developed an upload script for users to add photo's to my website but
I'd like the images to be reduced in actual size (width/height) on upload.
Anyone have any ideas on which script would be the best to achieve this?
Preferably it will fit in with my existing php code, which is:
$time = time();
$id= time().'-'.mt_rand(1000, 9999);
$newfilename = $id;
$extension = end(explode(".", $_FILES["file"]["name"]));
$poster = mysqli_real_escape_string($con, $_POST["formposter"]);
$type= mysqli_real_escape_string($con, $_POST["formtype"]);
$note= mysqli_real_escape_string($con, $_POST["formnote"]);
$path = "../posts/$type/";
//INSERT TO DATABASE
if(mysqli_affected_rows($con)>0){
//PHP REDUCE SIZE HERE I THINK
move_uploaded_file($_FILES["file"]["tmp_name"],"$path" . $newfilename
. "." . $extension);
header("Location: ../dashboard.php?page=posts");
exit();
}
else{
header("Location: ../404.php");
}
No comments:
Post a Comment