Hi guys I am stuck with my code, here is portion of the code keeps troubling me:
if($state == 'add'){//add state $upload_path = '/files/dir1/'; } else if($state == 'edit'){//edit state $upload_path = '/files/dir2/'; } $this->crud->set_field_upload('image_url', $upload_path);
Here I am trying to swap the $upload_path according to the current state. But this one is giving me the trouble. Everything is working fine except the file is getting uploaded to default $upload_dir which is set in the Grocery_CRUD.php. After spending a lot of time i found that the $state value is 'upload_file' for all the file uploads(regardless of the add or edit operations). i badly need to differentiate between the insert or update state. I tried to sort it out using
if(strpos($_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'], '/add')){ $upload_path = '/files/dir1/'; } else if(strpos($_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'], '/edit')){ $upload_path = '/files/dir2/'; }
strpos(current_url, '/add') strpos(current_url, '/edit')
Everything failed as the Grocery_CRUD.php library file is not able to tell me anything other than 'upload_file' as the current state.
Kindly help me! :(
Thanks in advance.