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? Quote Link to comment 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"); Quote Link to comment 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. ??? Quote Link to comment 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 } Quote Link to comment 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."; 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.