zetcoby Posted August 2, 2012 Share Posted August 2, 2012 hello, i have a small problem with my file upload script, for some reason the file size or and the file extensions conditions wont work, and i don`t know why, everything else works fine, if i wanna upload a file that has the right size it will upload, or if i upload a php file this one will upload too, i dont know why the condition wont kick in if (isset($_FILES['file'])){ $target = "../../uploads/"; $rand = rand(1, 9999); $target = $target . $rand . basename( $_FILES['file']['name']) ; $file_size = $_FILES['file']['size']; $file_ext = strtolower(end(explode('.', $_FILES['file']['name']))); if ($file_size >= 12000000) { header("Location: ../files/post?error=2&cid=".$cid); } if ($file_ext == 'php') { header("Location: ../files/post?error=3&cid=".$cid); } move_uploaded_file($_FILES['file']['tmp_name'], $target); } Quote Link to comment https://forums.phpfreaks.com/topic/266585-file-upload/ Share on other sites More sharing options...
jazzman1 Posted August 2, 2012 Share Posted August 2, 2012 Your form, please. Quote Link to comment https://forums.phpfreaks.com/topic/266585-file-upload/#findComment-1366352 Share on other sites More sharing options...
zetcoby Posted August 3, 2012 Author Share Posted August 3, 2012 i found the problem, it seems that the header function needs time to execute so all i had to do was to insert a die function after each header, Quote Link to comment https://forums.phpfreaks.com/topic/266585-file-upload/#findComment-1366526 Share on other sites More sharing options...
PFMaBiSmAd Posted August 3, 2012 Share Posted August 3, 2012 The header() statement only sends a http header to the browser. It's the browser that requests the new URL. Your php code continues to run. The die statement stops your php code from running at that point. Quote Link to comment https://forums.phpfreaks.com/topic/266585-file-upload/#findComment-1366527 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.