KoolReport's Forum

Official Support Area, Q&As, Discussions, Suggestions and Bug reports.
Forum's Guidelines

FileUploader does not work at all #3292

Closed Eugene opened this topic on on May 18 - 6 comments

Eugene commented on May 18

Hi, What do I do wrong?

class MyBoard extends Dashboard
{
    protected function content(){
       return[ FileUploader::create('myFileUploader')
            ->type('primary')
            ->accept(['jpg', 'png'])
            ->notAccept(['php'])
            ->maxFileSize(200000)
            ->imagePreview(true)
            ->showDownloadLink(true)
            ->previewWidth('150px')
            ->previewHeight('150px')
            ->fileName(function ($name, $ext) {
                return $name . '.' . $ext;
            })
            ->fileHandle(function ($file) {
                $name = $file['name'];
                $tmp = $file['tmp_name'];
                //You can do any thing to handle your file here
            })
            ->resolveValue(function ($file) {
                return $file['name'];
            })
           // ->resolveUrl(function ($value) {
          //      return "https://examples.com/images/$value";
           // })
            ->fileNotAllowedError('Not allowed')
            ->fileSizeLmitError('Oversized')
            ->unknownError('So mysterious')
            ->noFileError('No file was selected')
            ->noFileSelectedText('No file was selected')
            ->selectFileText('Select a file..')
       ];

    }
}

In Safari: The uploader input appears on the page, I can open the window to select a file. But it does not even filter the possible files in Safari. So I think it is perhaps not compatible with Safari... I always see No file selected. No Error messages anywhere

In Chrome: it filters but after I select the file I get the error message:

[Widget] myFileUploader
Message: Too few arguments to function ***Special\WineReport\Boards\MyBoard::Special\WineReport\Boards\{closure}(), 0 passed in /home/resto/domains/***/public_html/vendor/koolreport/dashboard/inputs/FileUploader.php on line 181 and exactly 1 expected
Line: 30
File: /home/resto/domains/***/public_html/src/Special/WineReport/Boards/MyBoard.php
 Collapse
#0: /home/resto/domains/***/public_html/vendor/koolreport/dashboard/inputs/FileUploader.php Line 181 : ***\Special\WineReport\Boards\{closure}(null)
#1: /home/resto/domains/***/public_html/vendor/koolreport/dashboard/inputs/FileUploader.php Line 73 : fileHandle(null)
#2: /home/resto/domains/***/public_html/vendor/koolreport/dashboard/TAction.php Line 37 : actionUpload(null)
#3: /home/resto/domains/***/public_html/vendor/koolreport/dashboard/Widget.php Line 128 : action(null)
#4: /home/resto/domains/***/public_html/vendor/koolreport/dashboard/Dashboard.php Line 262 : handle(null)
#5: /home/resto/domains/***/public_html/vendor/koolreport/dashboard/pages/Main.php Line 175 : handle(null)
#6: /home/resto/domains/***/public_html/vendor/koolreport/dashboard/Application.php Line 361 : handle(null)
#7: /home/resto/domains/***/public_html/vendor/koolreport/dashboard/Application.php Line 270 : handle(null)
#8: /home/resto/domains/***/public_html/index.php Line 6 : run(null)

As you can see I use exactly your example. except commented resolveUrl

KoolReport commented on May 19

Please remove the these line:

            ->fileHandle(function ($file) {
                $name = $file['name'];
                $tmp = $file['tmp_name'];
                //You can do any thing to handle your file here
            })

Let me know if it works.

Eugene commented on May 19

Thank you. It is better, There is no Too few arguments error message now, but I cannot say it works as I expected.

  1. I can choose any file even xls pdf etc - they are not downloaded but there is also no response... absolutely nothing is happened - no messages etc. So, what is the purpose of fileNotAllowedError

  2. If a file needs time to be downloaded it is also impossible to understand whether something is happening or not - there is no indication of progress or loading. It looks confusing when you cannot understand whether downloading is started or not.

And some more questions

  1. You suggested to delete fileHandle function but if I wish to change the file name where can I do it?
  2. If I want that after successful downloading the FlexView view will be changed where is the best place to do it?
Sebastian Morales commented on May 20

I think this is a bug with upload error and status displaying. We will release a new version of Dashboard this week to solve this and other issues you had with FileUploader.

Eugene commented on May 20

Sounds good even the week has just started... but what about my last two questions? Could you please give some comments?

Sebastian Morales commented on May 21

Your 2 questions about file name changing and updating upon successful upload would have solutions as well. Pls send us an email to support@koolreport.com and mention this topic so that we could send you an updated version of KoolReport Dashboard. Rgds,

Eugene commented on May 27

Thank you for you support. Some issues still exists. I sent the information about it to support@koolreport.com

Build Your Excellent Data Report

Let KoolReport help you to make great reports. It's free & open-source released under MIT license.

Download KoolReport View demo
help needed

Dashboard