Forum Moderators: coopster
just a slight problem with my upload.
If the file size is above 50k i display an error message but when i go back with the browser the page is expired how can i work around this please. code is as follows:-
<?php
if(!is_dir($store_dir) )
{
echo("Specified directory is not valid... Exiting");
@unlink($HTTP_POST_FILES['upfile']['tmp_name']);
exit();
}
if( copy($HTTP_POST_FILES['upfile']['tmp_name'],$store_dir.$test3) )
{
echo("");
}
else
{
echo("You did not select an image or<BR> 1. Image file was not jpeg<br>2. Image file was larger than 50k");
}
@unlink($HTTP_POST_FILES['upfile']['tmp_name']);
?>
I think i just need a php script that works like this
page 1 -
user selects file to upload
once file is selected check for filesize and if above 50k echo "Please select another image as it is to large" then once image is below 50k the error wont show and the form will submit.
does any body know if this can be done and is there a script out there?
[webmasterworld.com...]
Here is some stuff I use:
if(isset($_FILES['userfile']['error'])){
if($_FILES['userfile']['error'] == "1"){
$ErrorUpdateOK = false;
$ErrorMSG = 'The image you have attempted to upload is too large. (Max 2 Meg.)'.$_FILES['userfile']['error'];
}
if($_FILES['userfile']['error'] == "2"){
$ErrorUpdateOK = false;
$ErrorMSG = 'The image you have attempted to upload is too large. (Max 2 Meg.)'.$_FILES['userfile']['error'];
}
if($_FILES['userfile']['error'] == "3"){
$ErrorUpdateOK = false;
$ErrorMSG = 'The uploaded file was only partially uploaded.';
}
if($_FILES['userfile']['error'] == "4"){
$ErrorUpdateOK = false;
$ErrorMSG = 'No file was uploaded.';
}
}
}
hope that helps!