Hi i have this script to upload and replace the exciting image which is good. The one thing i can not figure out is i would like to resize any images that are uploaded, to like 60x60.
any ideas ?
<?php
if (isset($_POST['submit'])) {
$newext = '.png';
$filename = $_FILES["file"]["name"];
$file_basename = substr($filename, 0, strripos($filename, '.')); // get file extention
$file_ext = substr($filename, strripos($filename, '.')); // get file name
$filesize = $_FILES["file"]["size"];
$width = 20;
$height = 20;
$allowed_file_types = array('.jpg','.png','.gif');
if (in_array($file_ext,$allowed_file_types) && ($filesize < 2000)) {
// rename file
$newfilename = $_SESSION['ls_user'] . $newext;
{
move_uploaded_file($_FILES["file"]["tmp_name"], "avatar/" . $newfilename);
echo "File uploaded successfully.";
}
} elseif (empty($file_basename)) {
// file selection error
echo "Please select a file to upload.";
} elseif ($filesize > 2000) {
// file size error
echo "The file you are trying to upload is too large.";
} else {
// file type error
echo "Only these file typs are allowed for upload: " . implode(', ',$allowed_file_types);
unlink($_FILES["file"]["tmp_name"]);
}
}
?>
<p><form action="" method="post" enctype="multipart/form-data"></p>
<input type="file" name="file" id="file">
<input type="submit" name="submit" id="Submit" value="Submit"></form>
thank you