setFieldUploadMultiple

setFieldUploadMultiple(string $fieldName, string $privateUploadFolder, string $publicFolderPath [, array $options])

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 setFieldUploadMultiple 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. Keep in mind that only the name of the file (without the full path) is stored as comma separated values. We strongly recommend to use a field `TEXT` in the database so we can make sure that all the comma separated values are stored without a limitation.
  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

Example

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

Notice: Please have in mind that 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->setFieldUploadMultiple('profile_image', 'assets/uploads', base_url() . '/assets/uploads');

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

After version 2.9.0 we also have a 4th parameter into the function that you can specify the upload validations per field. More specifically we have:

Example:

$uploadValidations = [
    'maxUploadSize' => '20M', // 20 Mega Bytes
    'minUploadSize' => '1K', // 1 Kilo Byte
    'allowedFileTypes' => [
        'gif', 'jpeg', 'jpg', 'png', 'tiff'
    ]
];
$crud->setFieldUploadMultiple(
    'image', 
    'uploader/customer-image', 
    '/assets/images/customers', 
    $uploadValidations
);