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? Link to comment https://forums.phpfreaks.com/topic/175469-solved-if-uploaded_size-500/ 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. Link to comment https://forums.phpfreaks.com/topic/175469-solved-if-uploaded_size-500/#findComment-924624 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 Link to comment https://forums.phpfreaks.com/topic/175469-solved-if-uploaded_size-500/#findComment-924625 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. Link to comment https://forums.phpfreaks.com/topic/175469-solved-if-uploaded_size-500/#findComment-924628 Share on other sites More sharing options...
robert_gsfame Posted September 25, 2009 Share Posted September 25, 2009 it is in bytes Link to comment https://forums.phpfreaks.com/topic/175469-solved-if-uploaded_size-500/#findComment-924629 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"; } Link to comment https://forums.phpfreaks.com/topic/175469-solved-if-uploaded_size-500/#findComment-924630 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.