Greetings -
I would like to modify this script I wrote. I want it to use PHP's GD functions to resize the picture being submitted before it is added to the database.
Does anyone have any suggestions/code snippets/links?
Thank you -
[rednax]
if ($_POST[submitImage]) {
if (($_FILES['imagefile']['type'] == "image/pjpeg") || ($_FILES['imagefile']['type'] == "image/jpeg")) {
$path_file = $_FILES['imagefile']['tmp_name'];
$file_type = $_FILES['imagefile']['type'];
$file_name = $_FILES['imagefile']['name'];
$fp = fopen($path_file, "rb");
$binary_data = addslashes(fread($fp, 105000));
fclose($fp);
$success1 = "Correct file type... $file_type, $file_name";
} else {
$error = "Incorrect file type. The image you submitted was: $file_type.";
}
}
// submit binary to mysql DB
if (isset($success1)) {
$sql = "INSERT INTO $tbl_pictures (uid, picture, picture_name, type) VALUES ('$uid', '$binary_data', '$file_name', '$file_type')";
if($binary_result = mysql_query($sql,$connection)) {
$success2 = "Picture successfully uploaded.";
mysql_close();
Header("Location: create_account_s3.php");
exit;
}
}