Hello,
Now this is OK. There were several problems:
1/ The different URLs were not found because they were wrong: a segment was missing due to the fact that I work in subfolders. I solved the problem by looking at this: https://github.com/scoumbourdis/image-crud/issues/6
In libraries/image_crud.php I modified getState() and _get_delete_url().
In getState():
$rsegments_array = $this->ci->uri->rsegment_array();
/* Added part */
$segments_array = $this->ci->uri->segment_array();
$diff_uri = count($segments_array) - count($rsegments_array);
if($diff_uri)
{
$add_uri_array = array();
for($i = 1; $i <= $diff_uri; $i++) $add_uri_array[$i] = $segments_array[$i];
$add_uri = implode('/', $add_uri_array);
$add_uri .= '/';
} else $add_uri = '';
/* End of added part */
And in the rest of the function, I added $add_uri in all site_url(), for example:
$upload_url = site_url($add_uri.$rsegments_array[1].'/'.$rsegments_array[2].'/upload_file/'.$rsegments_array[3]);
I did the same in _get_delete_url().
2/ Then I encountered several issues to upload a file:
- I had a NOT NULL field in my table, and it caused an error at the insertion of the file_name in the table.
- if my primary key is not an auto-increment field, the insert statement also fails.
3/ 2 notices that are not in the documentation and seem important:
- the ordering field has to be numeric. I thought that it could be a character field depending on which images would be sorted.
- the relation field has to be numeric. I did not find yet how to modify the code so that character fields could be accepted. And it seems that a category should be provided in the URL otherwise it fails.
Finally, if the table contains other fields of description, they can neither be read nor edited, this would be great to able to do that! ;)
Juliette