php - Not able to stop processing form when image file has not been chosen -


i have form use submit new post images in. don't want post proceed submitting data server , database if user has not chosen image upload. @ moment try letting code continue processing form.

heres of code:

//check if submit button has been clicked         if( isset( $_post['submit'] ) ){              //validate title , description             $title = validate_title($_post['title']);             $desc = validate_desc($_post['desc']);              //get other posted variables             $cat = $_post['cat'];             $year = $_post['year'];              if($title && $desc != false){                  //check if image has been submitted                 if( $_files['files']['name'] != ""){... 

i have tried using following methods, neither stop code when no file has been selected:

if( $_files['files']['error'] == upload_err_ok){...  if( $_files['files']['name'] != upload_err_no_file){... 

it looks file input name files[], in case $_files["files"]["name"] array, check if user supplied image upload try,

foreach ($_files['files']["error"] $index => $error){     if ($error == upload_err_no_file){         //no file uploaded in $index`th file input      }     else{         //other checks , process $_files['files']['tmp_name'][$index]     } } 

Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -