⚠ 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 image outside of root directory



jrowe
  • profile picture
  • Member

Posted 30 July 2012 - 15:53 PM

Is it possible to set the upload directory outside of the root directory? Was going to try making a "test" site (for learning purposes) to process images outside of the root directory so users could not directly access the images through URLs. Could someone provide an example?

i.e..

set_field_upload('file_url','how/to/set/to/outside/directory');

thank you! :)

jrowe
  • profile picture
  • Member

Posted 16 August 2012 - 15:15 PM

is this possible?

Amit Shah
  • profile picture
  • Member

Posted 19 February 2014 - 05:32 AM

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 - copy / move the file from the upload path to your desired path... u will this way manage 2 save the file to your desired path. But everytime u want to display it - u have to programatically display it if the folder u uploaded is not a web accessible folder.

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