Here is my code
upload_form.php
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-7">
<meta name="Generator" content="Dev-PHP 1.3.0">
<title>Document Title</title>
</head>
<body>
<form method='post' action=upload_file2.php enctype='multipart/form-data'>
<input type='hidden' name='MAX_FILE_SIZE' value='20000'>
Enter the File <input type='file' name='userfile'> <br>
<input type='submit' name='submit' value='Send File'>
</form>
</body>
</html>
and that is the the upload_file2.php which executes the upload.
<? if($_POST['submit']) {
if($_FILES['userfile']['name']) {
echo $_POST['MAX_FILE_SIZE'];echo "<br>";
echo $_FILES['userfile']['size'];echo "<br>";
if(@($_FILES['userfile']['size'])>=($_POST['MAX_FILE_SIZE'])) {
echo "The file exceeds the limits";}
else {
$type_image=@getimagesize($_FILES['userfile']['tmp_name']);
if($type_image[2]){
$name=$_FILES['userfile']['name'];
if (is_uploaded_file($_FILES['userfile']['tmp_name']))
{
copy($_FILES['userfile']['tmp_name'], "images/".$name);
unlink($_FILES['userfile']['tmp_name']);
//optional
echo "<br> File successfully";
echo "<img src=images/".$name.">";}
}
else echo"You must enter an image file";}}
else echo "You must enter file";}
?>
The problem is that when i try to upload an image bigger than the limit i have set and in that case is only 20000 bytes, i revieve the following error message
Warning: MAX_FILE_SIZE of 20000 bytes exceeded - file [userfile=D:\brendan.jpg] not saved in Unknown on line 0
You must enter an image file
How could i halt this message by not displaying on the screen?
I want, when i attempt to upload something bigger, the "The file exceeds the limits" will be shown on the screen.
Is this practicable?
Thanks in advance!