Jump to content


Rename upload file

File gc

  • Please log in to reply
2 replies to this topic

#1 vhspiceros

vhspiceros

    Newbie

  • Members
  • Pip
  • 4 posts
  • LocationSantiago, Chile

Posted 27 January 2015 - 05: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.

 



#2 Amit Shah

Amit Shah

    grocery CRUD Master

  • Advanced Member
  • PipPipPip
  • 1,192 posts
  • LocationMumbai, India

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 :)



#3 vhspiceros

vhspiceros

    Newbie

  • Members
  • Pip
  • 4 posts
  • LocationSantiago, Chile

Posted 16 February 2015 - 07: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
}






Also tagged with one or more of these keywords: File, gc

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users