setFieldUpload

setFieldUpload(string $fieldName, string $privateUploadFolder, string $publicFolderPath)

There is a special type of field for uploading data or images and in order to trigger this type, you will need to use the setFieldUpload method. The usage is fairly easy and everything will work out of the box. You just need to make sure that the server has access to the specified folders.

The method is taking 3 parameters:

  1. The first parameter is the field name in the database. Have in mind that only the name of the file (without the full path) is stored
  2. The second parameter is the field that the file will actually be stored. If the path is the same as the public one then the second parameter will be the same with the 3rd
  3. The public path that the file can be accessed by the end-user that will need to be the full path

For example:

$crud->setFieldUpload('image', 'uploader/customer-image', '/assets/images/customers');

Notice: Please have in mind that the the public path will need to have the full URL of the folder. For example if you are using Codeigniter and the public path is the same with the private path then you will need to do something like this:

$crud->setFieldUpload('profile_image', 'assets/uploads', base_url() . '/assets/uploads');

For security reasons of this website we currently don't have a full example of the setFieldUpload.