如果要上传的图像超过 1mb,我需要知道如何处理此代码以减小/压缩要上传的图像的大小。
<form enctype="multipart/form-data" action='upcomg.php' method="post" name="changer">
<input name="MAX_FILE_SIZE" value="83886080" type="hidden">
<label>Please choose a file:</label><input name="image" accept="image/jpeg" type="file">
<input value="Submit" type="submit">
<?php
if (isset($_FILES['image']) && $_FILES['image']['size'] > 0) {
$tmpName = $_FILES['image']['tmp_name'];
$fp = fopen($tmpName, 'r');
$data = fread($fp, filesize($tmpName));
$data = addslashes($data);
fclose($fp);
$query = "INSERT INTO ### ";
$query .= "(##) VALUES ('$data')";
$results = mysql_query($query, $link);
// Print results
print "Thank you, your file has been uploaded.";
}
else {
print "No image selected/uploaded";
}
// Close our MySQL Link
mysql_close($link);
?>