Back To Front

Components for creates All Backend Widgets in Frontend pages (Lists, Search, Filter, Forms, FormWidgets, MediaManager, Reports) and manage this items

← Back to Back To Front Support

I can't get the image upload to work in the frontend. Any attempt to upload results in a red triangle over the thumbnail with an exclamation mark. Clicking the triangle creates a popup which says 'Upload error, validation.extensions' with the option to remove file. Is this a known problem or a configuration problem on my end? Every other form element works perfectly.

Speech about "fileupload"? Judging by the text of the error, the problem is with the extension of the uploaded file (validation of the file uploaded to the server does not pass). Check all possible limitations and settings of the fileupload widget (fileTypes, mimeTypes, maxFilesize). Also check the allowed extensions on the server side (Apache, Nginx ...)

Last updated

I added code for "uploadfile" in demo Model, All works fine: https://backtofront.test.linkonoid.com/useraccount/userclients/update/56

Main code in fields.yaml:

    avatar:
        label: 'Fileupload test'
        span: auto
        type: fileupload
        attachOnUpload: true
        mode: image
        imageHeight: 260
        imageWidth: 260
        thumbOptions:
            mode: crop
            offset:
                - 0
                - 0
            quality: 90
            sharpen: 0
            interlace: false
            extension: auto

In Model:

public $attachOne = [
     'avatar' => \System\Models\File::class
];

Last updated

public $attachOne = [ 'avatar' => \System\Models\File::class ];

What does the ::class do? When I try adding to my code it creates an error.

Error text? Check the code for extra spaces, etc (or error related to yaml?). Yaml format is very sensitive to leading spaces, check it for validity first of all.

https://stackoverflow.com/questions/30770148/what-is-class-in-php https://octobercms.com/docs/database/attachments#file-attachments

You can write like this (::class rets full class name with Name\Space included), all examples are correct and equivalent, including previously (\System\Models\File::class):

public $attachOne = [
    'avatar' => 'System\Models\File'
];

OR

use System\Models\File
//...
public $attachOne = [
    'avatar' => File::class
];

OR

use System\Models\File as AvatarFile
//...
public $attachOne = [
    'avatar' => AvatarFile::class
];

OR

public $attachOne = [
    'avatar' => System\Models\File::class
];

Last updated

Not sure what was causing the problem but I have reinstalled a fresh site and now the image upload is working. However, it seems you can only have one upload widget in a form. A simple test with a form with just two file uploads, let's say photo1 and photo2. Upload an image to photo1 and save the form. Then check and you will find that the image has been assigned to photo2 and not photo1.

1-6 of 6