⚠ 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

Upload to Dynamic Path



Hiro
  • profile picture
  • Member

Posted 25 May 2012 - 07:13 AM

I am working on a database system that will contain images however I would like for the images to uploaded into folders based on the Customer Name. So:

CUSTB001

Would go to /asset/CUSTB001/Images

So what I am asking is in the controller is there a way I can echo the contents of the id to the file path

Like this:
$crud->set_field_upload('file_url','assets/qa/'echo $custID'/images); //This way does not working but its the easiest way to explain what I am trying to do. I have looked in the library code and tried to figure out how the upload is done but I cant find any information regarding the path.

Any help is greatly appreciated.

fixwa
  • profile picture
  • Member

Posted 20 June 2012 - 03:33 AM

I think you can handle that by using callback_after_upload()

for instance:
$crud->callback_after_upload(array($this,'_callbackAfterUpload'));
.
....


public function _callbackAfterUpload($uploader_response,$field_info, $files_to_upload)
{
...handle the logic to move the file to its final destination..
return true;

}

jperl
  • profile picture
  • Member

Posted 15 March 2013 - 20:21 PM

Hi, the question is... how do i get a field value from a row ($custID, for example)  in callbackafterupload method?

Another solution (too complex) is create my own model with an extra calculated field that concats the path and the id: for example: path_image='/img/'.custID.'/portrait'

but the problem is the same... how put this value inside callback method or set_field_upload method?

 

something similar:

$crud->set_field_upload('file_url',$crud-> column('path_image');

 

any ideas?

thanks!