⚠ 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

Rename upload file



vhspiceros

vhspiceros
  • profile picture
  • Member

Posted 27 January 2015 - 17:39 PM

Dear all,
I am new in grocery crud, by the by is an incredible extension, congratulations ;)
the question is, I have one form and one field is a type File. I need change the name for the identify object, for example
.
I have the invoice table and one file field, i need when the user save the system should rename the file by id generate plus extension.
 
If I save the invoice number 18 i need save the file with name 18.pdf.
Thanks in advance.
 
Note: sorry by my english.

 


Amit Shah

Amit Shah
  • profile picture
  • Member

Posted 29 January 2015 - 09:49 AM

well my friend u can use callback_after_insert

there once u have inserted - u get the id of the record saved.. u can use it .. to rename the file tht was uploaded along with that record.

Rename the file physically and also update the record with the same name...

 

Happy GCing :)


vhspiceros

vhspiceros
  • profile picture
  • Member

Posted 16 February 2015 - 19:02 PM

Yes,  I found the solution ;)

$crud->callback_after_insert(array($this, 'rename_img_db'));
public function rename_img_db($post_array,$primary_key){
        //Here goes the get and set querys with your $primary_key
}