⚠ 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 multiple files



drramki

drramki
  • profile picture
  • Member

Posted 05 March 2015 - 20:03 PM

Not sure if this is answered already. However, this is what am trying to do:

 

I am uploading 3 files to the server and would like to rename files based on inputs from the user. specifically this post: http://stackoverflow.com/questions/15296963/multiple-upload-with-grocery-crud

 

$crud->columns('project','user');

$crud->set_field_upload('file1','assets/files');

$crud->set_field_upload('file2','assets/files');

$crud->call_back_after_upload(array($this,'my_function');

 

I took hints from other posts and tried this:

 

public function my_function($post_array,$files_to_upload,$uploader_response,$field_info){

    switch ($field_info) {

        case 'file1':

             $uploader_response[0]->name = $post_array['project'] . '_' . $post_array['user'] . '_file1.png' 

        case 'file2':

             $uploader_response[0]->name = $post_array['project'] . '_' . $post_array['user'] . '_file2.png'

    }

 

I couldn't find a way to fix this. Any advice is appreciated. Thanks.