scoumbourdis / grocery-crud-codeigniter-4

GNU General Public License v3.0
68 stars 38 forks source link

Error using set_field_upload #4

Closed difagume closed 4 years ago

difagume commented 4 years ago

Hi Johnny thanks for the help,

when using set_field_upload() I'm having errors showing the image and trying to upload an image, my code is:

public function index()
    {
        $crud = new GroceryCrud();

        $crud->setTable('noticia')
            ->set_subject('Noticia')
            ->setRelation('categoria_id', 'categoria', 'descripcion')
            ->displayAs('categoria_id', 'Categoría')
            ->columns(['titulo', 'autor', 'fecha_publicacion', 'contenido', 'imagen', 'categoria_id'])
        //->addFields(['titulo', 'autor', 'fecha_publicacion', 'contenido', 'imagen', 'categoria_id'])

            ->set_field_upload('imagen', 'assets/images');

        /* ->callback_before_insert(function ($noticia_array) {
        $noticia_array['ref'] = url_title($noticia_array['titulo']);
        return $noticia_array;
        }); */

        $output = $crud->render();

        return $this->_crud_noticias_output($output);
    }

according to the indications I should not place / at the beginning ->set_field_upload('imagen', 'assets/images');

but in the browser I join public with assets, as you can see in the image, instead if I put:

->set_field_upload('imagen', '/assets/images'); the images if they appear.

error

my baseUrl parameter in App.php is: public $baseURL = 'http://localhost/noticias/public/';

and when I try to load an image I get the following errors:

error2

I wanted to report it, I don't know if it's because of lack of any configuration in my site, any help is very appreciated.

scoumbourdis commented 4 years ago

Hello @difagume as this is still work in progress, I haven't completed the work for upload fields. What I am doing currently is that I am going one by one function and try to change the name and see that it works. More specifically for the functions that are working you can check the README file here: https://github.com/scoumbourdis/grocery-crud-codeigniter-4/blob/master/README.md

A simple rule to remember is, if you see that the name of the function is still snake_case (e.g. set_field_upload) then this is probably a function that it is not implemented yet (it may work but this doesn't mean that it was also tested).

On the other side when a function is with name camelCase (e.g. setTable) that means that this is now in a working state.

I hope it helped.

Regards Johnny

SomSankar commented 4 years ago

Any approximate time when this file upload thing will be updated on the library?