⚠ In case you've missed it, we have migrated to our new website, with a brand new forum. For more details about the migration you can read our blog post for website migration. This is an archived forum. ⚠

  •     

profile picture

How to work with input type "file"



ali_abdelrhim
  • profile picture
  • Member

Posted 29 December 2015 - 12:20 PM

Hi;

 

   I am using grocery crud to create read, update and delete records from table that contain one filed to save photo path. it is ok to deal with photo as "varchar" when reading and inserting, but I need to add input type in create "Add" form to make it easy for end user to select the photo by browsing files in computer and select the target photo. I could add it by adding some if statement in add form: 

<?php if ($field->field_name == 'image'): ?>
 
<?php $input_fields[$field->field_name]->input = "<input id=field-$field->field_name class='form-control' name=$field->field_name type='file'  />"; ?>
<?php endif;?>

 

but saving data in the table is not working, each time when I press save button to save the record I found this field "image" empty. 

my question is: first I need to know how to trace the $_POST before send to database to see if the field is posting correctly or not? 

second, how to deal with input type "file" in add and edit ? 

 

thanks.