⚠ 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

want to set upload path above my CI project



bob jones

bob jones
  • profile picture
  • Member

Posted 16 May 2012 - 21:24 PM

Hi,

I would like to set my upload path to a folder outside and above the level of my CI project, using the set_field_upload function. My attempts so far have led to an upload error message.

Is this possible? If not is there a work around?

Thank you,

Bill

web-johnny

web-johnny
  • profile picture
  • Administrator
  • 1,166 posts

Posted 23 May 2012 - 21:17 PM

Hello Bill,

can you be more specific of what exactly you want to do with an example? You can of course have the folder outside of the ci project. But you have to describe your problem to help you with this.

Regards
Johnny

bob jones

bob jones
  • profile picture
  • Member

Posted 24 May 2012 - 14:06 PM

Thanks for looking at this Web-johnny,

Sorry for the confusion. I have A CI project containing grocery Crud in a folder called ionauth1 which is in my server's public_html directory. I access it like http://mydomain.com/ionauth1/ .

Lets say I want to upload files to the root directory http://mydomain.com/ , can I do this ?

from reading in the documentation ( http://www.grocerycrud.com/examples/set_upload_field_example ) , I know that:

" you cannot insert "/assets/uploads/files", because it will not work. " . I had tried to use '../assets/uploads/files', but this does not work either.

Thank you.

Bill

web-johnny

web-johnny
  • profile picture
  • Administrator
  • 1,166 posts

Posted 24 May 2012 - 18:57 PM

No, for now you cannot do this as grocery CRUD doesn't support yet. I thought when you meant outside you meant outside the application.

You have to change the functionality of grocery CRUD and the uploader to do this kind of thing. I will have it in mind to have this kind of task in the future. I am sorry that I cannot help you with this :(

duangsin.k

duangsin.k
  • profile picture
  • Member

Posted 25 May 2012 - 08:21 AM

[quote name='bob jones' timestamp='1337203491' post='1804']
Hi,

I would like to set my upload path to a folder outside and above the level of my CI project, using the set_field_upload function. My attempts so far have led to an upload error message.

Is this possible? If not is there a work around?

Thank you,

Bill
[/quote]




Hi Bill ,


function employees_management()
{
$crud = new grocery_CRUD();

$crud->set_theme('datatables');
$crud->set_table('employees');
$crud->set_relation('officeCode','offices','city');
$crud->display_as('officeCode','Office City');
$crud->set_subject('Employee');

$crud->required_fields('lastName');

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

$output = $crud->render();

$this->_example_output($output);
}



Reffernce link => http://www.grocerycrud.com/examples/set_upload_field_example


....
thank
Duangsin

ricardo

ricardo
  • profile picture
  • Member

Posted 01 June 2012 - 19:02 PM

You can!

Try this:

$crud->set_field_upload('logo', $_SERVER['DOCUMENT_ROOT'].'/images/logos');


Where image/logos is at the root of your server. It is working for me.

Hope this helps!

Regards,

Ricardo

MiamMiam

MiamMiam
  • profile picture
  • Member

Posted 09 February 2014 - 14:12 PM

This does not work for me :

$crud->set_field_upload('logo', $_SERVER['DOCUMENT_ROOT'].'/images/logos');

But this does :

$crud->set_field_upload('logo', '../images/logos');

The image folder is located at the same level as the CI folder.

 

Ciao


Amit Shah

Amit Shah
  • profile picture
  • Member

Posted 19 February 2014 - 05:31 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:)