I`m uploading images to the database for my website,it works fine))
I want them to be resized to width=160 and height=140.
now i dont know if i should resize them before uploading them to mysql database Or while Displaying them.
Also i dont have Knowledge concerning resize of image.
Please help me in this:
Below is the code i`m using for uploadig images
the max file size is 1052695
<?php
if ($_POST['submit']) {
$user=$_POST['user'];
$id=$_POST['userid'];
if ($_POST['MAX_FILE_SIZE'] >= $_FILES['file']['size']) {
$filetype=$_FILES['file']['type'];
//print_r($_FILES);
include"config.php";
$photo = addslashes(fread(fopen($_FILES['file']['tmp_name'], "r"),
$_FILES['file']['size']));
$query = "INSERT INTO image SET image='$photo',filetype='$filetype',user='$user',userid='$id' WHERE user='$user'";
$result=mysql_query($query);
if ($result) {
echo "Your files is successfully stored in database";
//include"myprofile.php";
} else {
echo"Error detected while trying TO add YOUR photo<br> Try again please";
}
}ELSE{
echo"the file is bigger than the size needed";
}
}
}
?>