merylvingien Posted November 30, 2010 Share Posted November 30, 2010 Having an issue where a peice of code is just being ignored. <?php if($_POST){ $image =$_FILES["image"]["name"]; $img = $_FILES['image']['tmp_name']; $size= filesize($_FILES["image"]["name"]); $maxsize= 400; if ($size > $maxsize*1024){ echo "File too big"; exit(); } else { That is the first bit of code in the page, if i upload a image within the size allowance everything is ok, but if i try one which is a lot bigger, it ignore the if $size > statement and just continues on and throws a bunch of errors. Any ideas? Quote Link to comment https://forums.phpfreaks.com/topic/220271-filesize-function/ Share on other sites More sharing options...
AbraCadaver Posted November 30, 2010 Share Posted November 30, 2010 Because $_FILES["image"]["name"] is not the path to the actual file, so $size = false. Try: $size = filesize($_FILES["image"]["tmp_name"]); Quote Link to comment https://forums.phpfreaks.com/topic/220271-filesize-function/#findComment-1141468 Share on other sites More sharing options...
gookymedia Posted November 30, 2010 Share Posted November 30, 2010 Online AbraCadaver - Just to point out I think your tag line is quite well thought of! Quote Link to comment https://forums.phpfreaks.com/topic/220271-filesize-function/#findComment-1141481 Share on other sites More sharing options...
merylvingien Posted November 30, 2010 Author Share Posted November 30, 2010 Thanks for the reply, but still doesnt work, although the error messages have changed, i cant see why this wont work... Quote Link to comment https://forums.phpfreaks.com/topic/220271-filesize-function/#findComment-1141483 Share on other sites More sharing options...
merylvingien Posted November 30, 2010 Author Share Posted November 30, 2010 Actually its working fine, but as i was loading a file which was larger than the allowed size in the php.ini file, thats why the errors were throwing up. Researching how to prevent a larger than allowed file to be uploaded and prevent the errors to start with. Quote Link to comment https://forums.phpfreaks.com/topic/220271-filesize-function/#findComment-1141501 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.