Gayner Posted September 25, 2009 Share Posted September 25, 2009 When i use if ($uploaded_size > 500) { echo "Your file is too large.<br>"; $ok=0; } is >500 represent bytes? or kilobytes? Quote Link to comment Share on other sites More sharing options...
JasonLewis Posted September 25, 2009 Share Posted September 25, 2009 Well, it depends what $uploaded_size is. $uploaded_size could be in MB, then 500 could represent MB. Quote Link to comment Share on other sites More sharing options...
Gayner Posted September 25, 2009 Author Share Posted September 25, 2009 Well, it depends what $uploaded_size is. $uploaded_size could be in MB, then 500 could represent MB. How do i found out what uploaded size is? rofll theres no other variable named that Quote Link to comment Share on other sites More sharing options...
JasonLewis Posted September 25, 2009 Share Posted September 25, 2009 It would most likely be in bytes. If it was retrieved from $_FILES['userfile']['size'] then it is in bytes. Quote Link to comment Share on other sites More sharing options...
robert_gsfame Posted September 25, 2009 Share Posted September 25, 2009 it is in bytes Quote Link to comment Share on other sites More sharing options...
Gayner Posted September 25, 2009 Author Share Posted September 25, 2009 if ((($_FILES["file"]["type"] == "image/gif") || ($_FILES["file"]["type"] == "image/jpeg") || ($_FILES["file"]["type"] == "image/pjpeg")) && ($_FILES["file"]["size"] < 10000)) { if ($_FILES["file"]["error"] > 0) { echo "Return Code: " . $_FILES["file"]["error"] . "<br />"; } else { echo "Upload: " . $_FILES["file"]["name"] . "<br />"; echo "Type: " . $_FILES["file"]["type"] . "<br />"; echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />"; echo "Temp file: " . $_FILES["file"]["tmp_name"] . "<br />"; if (file_exists("avatars/" . $_FILES["file"]["name"])) { echo $_FILES["file"]["name"] . " already exists. "; } else { move_uploaded_file($_FILES["file"]["tmp_name"], "avatars/" . $_FILES["file"]["name"]); echo "Stored in: " . "avatars/" . $_FILES["file"]["name"]; } } } else { echo "Invalid file"; } Quote Link to comment 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.