zeusthegreat Posted March 7, 2011 Report Share Posted March 7, 2011 function upload($file_id, $folder="", $types="") { if(!$_FILES[$file_id]['name']) return array('','No file specified'); $file_title = $_FILES[$file_id]['name']; //Get file extension $ext_arr = split("\.",basename($file_title)); $ext = strtolower($ext_arr[count($ext_arr)-1]); //Get the last extension //Not really uniqe - but for all practical reasons, it is $uniqer = substr(md5(uniqid(rand(),1)),0,5); $file_name = $uniqer . '_' . $file_title;//Get Unique Name $all_types = explode(",",strtolower($types)); if($types) { if(in_array($ext,$all_types)); else { $result = "'".$_FILES[$file_id]['name']."' is not a valid file."; //Show error if any. return array('',$result); } } WHAT I MEAN IS if(!$_FILES[$file_id]['name']) return array('','No file specified'); WHAT DOES THE EXCLAMATION MARK MEAN BEFORE $_FILES HAVE GOOGLED AND I GET DIFFERENT ANSWERS, SO THOUGHT I WOULD ASK SOMEBODY WHO WOULD KNOW FOR CERTAIN Quote Link to comment Share on other sites More sharing options...
falkencreative Posted March 7, 2011 Report Share Posted March 7, 2011 The "!" indicates that the if statement checks for a false result. In this case, that particular statements reads "if $_FILES[$file_id]['name'] == false, return the array(...). Make sense? 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.
Note: Your post will require moderator approval before it will be visible.