⚠ 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

Help me with Upload FILE



Patricia Benítez

Patricia Benítez
  • profile picture
  • Member

Posted 15 February 2014 - 20:57 PM

first im sorry im learning english and i need help with grocery crud.............

I need to upload a file using grocery crud and i want to save the file only and my computer not in my Data Base...

 

I have something like this, but this code only save me the name of the file and the data base , i a repeat i want to save the file in  a specific folder in my computer...

  • $crud->set_field_upload('AR_DOCUMENTO_LEY','assets/uploads/files');

MiamMiam

MiamMiam
  • profile picture
  • Member

Posted 16 February 2014 - 16:11 PM

Hi Patricia,

 

this might help : /topic/451-want-to-set-upload-path-above-my-ci-project/


ceroberoz

ceroberoz
  • profile picture
  • Member

Posted 16 February 2014 - 18:22 PM

well, the database only store the path to the file.

the file itself is stored in your computer.

 

if you use this code

$crud->set_field_upload('your_column','assets/uploads/files')

then you will find the uploaded file in the assets/uploads/files of your CI installation


Patricia Benítez

Patricia Benítez
  • profile picture
  • Member

Posted 17 February 2014 - 15:50 PM

Thank`s for your help
But if i dont want to save the uploaded file in my CI installation, i want to put the file in my documents or images in my computer

Amit Shah

Amit Shah
  • profile picture
  • Member

Posted 19 February 2014 - 05:29 AM

Hi Patricia Benítez

 

Technically this is not possible.Grocerycrud library wont allow you to save your files outside the application. But there is a way to achieve it - you need to alter the code to allow you to set a hardbound path where u can go and upload. But this may give trouble for the library to pickback the file from the given path and render it as output - so not recomended

 

This scenario is again not a practical solution on server side as if its a shared server - u might not have any option  like this other then the folder / files alloted to u.

Again when u plan to display this - it will not be able to do it properly unless it is part of some web accessible folder.

 

There are other way you can do to achieve the same functionality without temporing the code...

1 - use callback_after_upload .. once the file is uploaded - move the file from the upload path to your desired path... u will this way manage 2 save the file to your desired path.

2 - Other way in linux system - u can achieve this even without the callback.. create a softlink of the folder u want to upload the files to into the assets/uploads folder and set the file upload path to that softlink and it should directly save the file to the desired path.

 

Happy GCing:)