phpSensei Posted July 28, 2007 Share Posted July 28, 2007 I have an upload application fixed up and everything but I seem to have one problem. I can get the file size but it just shows up numbers like "2323", but does not show the KB, GB , MB or anything.. Is there any function that can count the file size to megabytes if it exceeds 1000 kb? or if it is less than 1000 it shows kb? Link to comment https://forums.phpfreaks.com/topic/62123-get-filesize/ Share on other sites More sharing options...
tibberous Posted July 28, 2007 Share Posted July 28, 2007 Try this: $size = ( $size > 1024 ? round($size/1024, 2) . "mb" : $size."kb"); Link to comment https://forums.phpfreaks.com/topic/62123-get-filesize/#findComment-309284 Share on other sites More sharing options...
phpSensei Posted July 28, 2007 Author Share Posted July 28, 2007 Thankyou, it worked... I just have this other problem... I want to allow png, jpeg, and other sort of files, so I did this : image/png...etc it doesnt work. ??? Link to comment https://forums.phpfreaks.com/topic/62123-get-filesize/#findComment-309295 Share on other sites More sharing options...
teng84 Posted July 28, 2007 Share Posted July 28, 2007 try doing something like this $arr_value= array('jpeg','mpeg','etc'); if( in_array($variable,$arr_value)){ //then do some stuff here } Link to comment https://forums.phpfreaks.com/topic/62123-get-filesize/#findComment-309307 Share on other sites More sharing options...
tibberous Posted July 28, 2007 Share Posted July 28, 2007 if(!$_FILES['_image']) return "Error encoding file"; $name = explode('.', $_FILES["_image"]["name"]); $ext = $name[count($name)-1]; $ext = strtolower($ext); if($ext == "jpeg") $ext == "jpg"; if($ext != "jpg" && $ext != "png" && $ext != "gif") return "Invalid filetype."; Link to comment https://forums.phpfreaks.com/topic/62123-get-filesize/#findComment-309310 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.