• Extensions
  • FriendsOfFlarum upload, the intelligent file attachment extension

Published 0.4.3 that fixes the filename problem adding the old extension into the name.

    luceos Thank you. I have proposed a change to fr.yml. This should be now available for your review.

    luceos I'm not sure, could you specify your issue?

    i want to multi files upload(over 2 files),
    files name is 2byte language(한글.jpg) .. cannot upload. but one file upload is ok.
    when try 2 files (한글파일.jpg + 샘플파일.png) upload..error "Oops! Something went wrong. Please reload the page and try again."
    when try 2files (샘플파일.jpg + samplefile.gif).. multi-upload is performed.

    so i cannot multi-upload (files name is korean) over 2 files.

    Is there enough explanation?

      wowmac

      If I understand you correctly. You have had success with exactly one or two file uploads in a single post, while any more than this gives an error. Is that correct?

      I haven't checked to see if this errors for me yet, but am wondering if you've checked limitations of your webserver or php configuration. By default, php will only allow 2MB or 8MB. You could simple be hitting that limit.

      Another thought @luceos is the size limit for upload in the extension settings per file or per post?

        webeindustry

        It's not a matter of capacity.
        The problem is that the file name is in Korean.
        If the file name is korean, it means that if you try to upload more than 2 files, an error occurs.
        I'm sorry I did not speak English well.

        Please note that the capacity of uploaded files does not exceed 1 megabyte.

          wowmac

          No worries. Curious that error occurs. Hoping luceos has an idea here, I'd like to know why that happens.

          wowmac enable debug and see what the exact error is (debug button next to the woops message). Without this error message it's very difficult to pinpoint the issue.

            luceos
            when debug is true and retry, this error massege..

            POST http://witple.com/api/flagrow/upload
            
            {
              "errors": [
                {
                  "code": 500,
                  "title": "Internal server error",
                  "detail": "League\\Flysystem\\FileExistsException: File already exists at path: 2017-01-30/08:22:070-.jpeg in /home/witple/public_html/vendor/league/flysystem/src/Filesystem.php:401\nStack trace:\n#0 /home/witple/public_html/vendor/league/flysystem/src/Filesystem.php(81): League\\Flysystem\\Filesystem->assertAbsent('2017-01-30/08:2...')\n#1 /home/witple/public_html/vendor/flagrow/upload/src/Adapters/Flysystem.php(52): League\\Flysystem\\Filesystem->writeStream('2017-01-30/08:2...', Resource id #69)\n#2 /home/witple/public_html/vendor/flagrow/upload/src/Commands/UploadHandler.php(135): Flagrow\\Upload\\Adapters\\Flysystem->upload(Object(Flagrow\\Upload\\File), Object(Symfony\\Component\\HttpFoundation\\File\\UploadedFile), Resource id #69)\n#3 [internal function]: Flagrow\\Upload\\Commands\\UploadHandler->Flagrow\\Upload\\Commands\\{closure}(Object(Flagrow\\Upload\\File), 1)\n#4 /home/witple/public_html/vendor/illuminate/support/Collection.php(469): array_map(Object(Closure), Array, Array)\n#5 /home/witple/public_html/vendor/flagrow/upload/src/Commands/UploadHandler.php(166): Illuminate\\Support\\Collection->map(Object(Closure))\n#6 [internal function]: Flagrow\\Upload\\Commands\\UploadHandler->handle(Object(Flagrow\\Upload\\Commands\\Upload))\n#7 /home/witple/public_html/vendor/illuminate/bus/Dispatcher.php(202): call_user_func(Array, Object(Flagrow\\Upload\\Commands\\Upload))\n#8 [internal function]: Illuminate\\Bus\\Dispatcher->Illuminate\\Bus\\{closure}(Object(Flagrow\\Upload\\Commands\\Upload))\n#9 /home/witple/public_html/vendor/illuminate/pipeline/Pipeline.php(139): call_user_func(Object(Closure), Object(Flagrow\\Upload\\Commands\\Upload))\n#10 [internal function]: Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Flagrow\\Upload\\Commands\\Upload))\n#11 /home/witple/public_html/vendor/illuminate/pipeline/Pipeline.php(102): call_user_func(Object(Closure), Object(Flagrow\\Upload\\Commands\\Upload))\n#12 /home/witple/public_html/vendor/illuminate/bus/Dispatcher.php(204): Illuminate\\Pipeline\\Pipeline->then(Object(Closure))\n#13 /home/witple/public_html/vendor/illuminate/bus/Dispatcher.php(177): Illuminate\\Bus\\Dispatcher->dispatchNow(Object(Flagrow\\Upload\\Commands\\Upload), NULL)\n#14 /home/witple/public_html/vendor/flagrow/upload/src/Api/Controllers/UploadController.php(52): Illuminate\\Bus\\Dispatcher->dispatch(Object(Flagrow\\Upload\\Commands\\Upload))\n#15 /home/witple/public_html/vendor/flarum/core/src/Api/Controller/AbstractSerializeController.php(96): Flagrow\\Upload\\Api\\Controllers\\UploadController->data(Object(Zend\\Stratigility\\Http\\Request), Object(Tobscure\\JsonApi\\Document))\n#16 /home/witple/public_html/vendor/flarum/core/src/Http/Handler/ControllerRouteHandler.php(52): Flarum\\Api\\Controller\\AbstractSerializeController->handle(Object(Zend\\Stratigility\\Http\\Request))\n#17 /home/witple/public_html/vendor/flarum/core/src/Http/Middleware/DispatchRoute.php(71): Flarum\\Http\\Handler\\ControllerRouteHandler->__invoke(Object(Zend\\Stratigility\\Http\\Request), Array)\n#18 /home/witple/public_html/vendor/zendframework/zend-stratigility/src/Dispatch.php(224): Flarum\\Http\\Middleware\\DispatchRoute->__invoke(Object(Zend\\Stratigility\\Http\\Request), Object(Zend\\Stratigility\\Http\\Response), Object(Zend\\Stratigility\\Next))\n#19 /home/witple/public_html/vendor/zendframework/zend-stratigility/src/Dispatch.php(88): Zend\\Stratigility\\Dispatch->dispatchCallableMiddleware(Object(Flarum\\Http\\Middleware\\DispatchRoute), Object(Zend\\Stratigility\\Next), Object(Zend\\Stratigility\\Http\\Request), Object(Zend\\Stratigility\\Http\\Response), NULL)\n#20 /home/witple/public_html/vendor/zendframework/zend-stratigility/src/Next.php(160): Zend\\Stratigility\\Dispatch->__invoke(Object(Zend\\Stratigility\\Route), NULL, Object(Zend\\Stratigility\\Http\\Request), Object(Zend\\Stratigility\\Http\\Response), Object(Zend\\Stratigility\\Next))\n#21 /home/witple/public_html/vendor/flarum/core/src/Http/Middleware/SetLocale.php(50): Zend\\Stratigility\\Next->__invoke(Object(Zend\\Stratigility\\Http\\Request), Object(Zend\\Stratigility\\Http\\Response))\n#22 /home/witple/public_html/vendor/zendframework/zend-stratigility/src/Dispatch.php(224): Flarum\\Http\\Middleware\\SetLocale->__invoke(Object(Zend\\Stratigility\\Http\\Request), Object(Zend\\Stratigility\\Http\\Response), Object(Zend\\Stratigility\\Next))\n#23 /home/witple/public_html/vendor/zendframework/zend-stratigility/src/Dispatch.php(88): Zend\\Stratigility\\Dispatch->dispatchCallableMiddleware(Object(Flarum\\Http\\Middleware\\SetLocale), Object(Zend\\Stratigility\\Next), Object(Zend\\Stratigility\\Http\\Request), Object(Zend\\Stratigility\\Http\\Response), NULL)\n#24 /home/witple/public_html/vendor/zendframework/zend-stratigility/src/Next.php(160): Zend\\Stratigility\\Dispatch->__invoke(Object(Zend\\Stratigility\\Route), NULL, Object(Zend\\Stratigility\\Http\\Request), Object(Zend\\Stratigility\\Http\\Response), Object(Zend\\Stratigility\\Next))\n#25 /home/witple/public_html/vendor/flarum/core/src/Http/Middleware/AuthenticateWithHeader.php(57): Zend\\Stratigility\\Next->__invoke(Object(Zend\\Stratigility\\Http\\Request), Object(Zend\\Stratigility\\Http\\Response))\n#26 /home/witple/public_html/vendor/zendframework/zend-stratigility/src/Dispatch.php(224): Flarum\\Http\\Middleware\\AuthenticateWithHeader->__invoke(Object(Zend\\Stratigility\\Http\\Request), Object(Zend\\Stratigility\\Http\\Response), Object(Zend\\Stratigility\\Next))\n#27 /home/witple/public_html/vendor/zendframework/zend-stratigility/src/Dispatch.php(88): Zend\\Stratigility\\Dispatch->dispatchCallableMiddleware(Object(Flarum\\Http\\Middleware\\AuthenticateWithHeader), Object(Zend\\Stratigility\\Next), Object(Zend\\Stratigility\\Http\\Request), Object(Zend\\Stratigility\\Http\\Response), NULL)\n#28 /home/witple/public_html/vendor/zendframework/zend-stratigility/src/Next.php(160): Zend\\Stratigility\\Dispatch->__invoke(Object(Zend\\Stratigility\\Route), NULL, Object(Zend\\Stratigility\\Http\\Request), Object(Zend\\Stratigility\\Http\\Response), Object(Zend\\Stratigility\\Next))\n#29 /home/witple/public_html/vendor/flarum/core/src/Http/Middleware/AuthenticateWithSession.php(33): Zend\\Stratigility\\Next->__invoke(Object(Zend\\Stratigility\\Http\\Request), Object(Zend\\Stratigility\\Http\\Response))\n#30 /home/witple/public_html/vendor/zendframework/zend-stratigility/src/Dispatch.php(224): Flarum\\Http\\Middleware\\AuthenticateWithSession->__invoke(Object(Zend\\Stratigility\\Http\\Request), Object(Zend\\Stratigility\\Http\\Response), Object(Zend\\Stratigility\\Next))\n#31 /home/witple/public_html/vendor/zendframework/zend-stratigility/src/Dispatch.php(88): Zend\\Stratigility\\Dispatch->dispatchCallableMiddleware(Object(Flarum\\Http\\Middleware\\AuthenticateWithSession), Object(Zend\\Stratigility\\Next), Object(Zend\\Stratigility\\Http\\Request), Object(Zend\\Stratigility\\Http\\Response), NULL)\n#32 /home/witple/public_html/vendor/zendframework/zend-stratigility/src/Next.php(160): Zend\\Stratigility\\Dispatch->__invoke(Object(Zend\\Stratigility\\Route), NULL, Object(Zend\\Stratigility\\Http\\Request), Object(Zend\\Stratigility\\Http\\Response), Object(Zend\\Stratigility\\Next))\n#33 /home/witple/public_html/vendor/flarum/core/src/Http/Middleware/RememberFromCookie.php(38): Zend\\Stratigility\\Next->__invoke(Object(Zend\\Stratigility\\Http\\Request), Object(Zend\\Stratigility\\Http\\Response))\n#34 /home/witple/public_html/vendor/zendframework/zend-stratigility/src/Dispatch.php(224): Flarum\\Http\\Middleware\\RememberFromCookie->__invoke(Object(Zend\\Stratigility\\Http\\Request), Object(Zend\\Stratigility\\Http\\Response), Object(Zend\\Stratigility\\Next))\n#35 /home/witple/public_html/vendor/zendframework/zend-stratigility/src/Dispatch.php(88): Zend\\Stratigility\\Dispatch->dispatchCallableMiddleware(Object(Flarum\\Http\\Middleware\\RememberFromCookie), Object(Zend\\Stratigility\\Next), Object(Zend\\Stratigility\\Http\\Request), Object(Zend\\Stratigility\\Http\\Response), NULL)\n#36 /home/witple/public_html/vendor/zendframework/zend-stratigility/src/Next.php(160): Zend\\Stratigility\\Dispatch->__invoke(Object(Zend\\Stratigility\\Route), NULL, Object(Zend\\Stratigility\\Http\\Request), Object(Zend\\Stratigility\\Http\\Response), Object(Zend\\Stratigility\\Next))\n#37 /home/witple/public_html/vendor/flarum/core/src/Http/Middleware/StartSession.php(33): Zend\\Stratigility\\Next->__invoke(Object(Zend\\Stratigility\\Http\\Request), Object(Zend\\Stratigility\\Http\\Response))\n#38 /home/witple/public_html/vendor/zendframework/zend-stratigility/src/Dispatch.php(224): Flarum\\Http\\Middleware\\StartSession->__invoke(Object(Zend\\Stratigility\\Http\\Request), Object(Zend\\Stratigility\\Http\\Response), Object(Zend\\Stratigility\\Next))\n#39 /home/witple/public_html/vendor/zendframework/zend-stratigility/src/Dispatch.php(88): Zend\\Stratigility\\Dispatch->dispatchCallableMiddleware(Object(Flarum\\Http\\Middleware\\StartSession), Object(Zend\\Stratigility\\Next), Object(Zend\\Stratigility\\Http\\Request), Object(Zend\\Stratigility\\Http\\Response), NULL)\n#40 /home/witple/public_html/vendor/zendframework/zend-stratigility/src/Next.php(160): Zend\\Stratigility\\Dispatch->__invoke(Object(Zend\\Stratigility\\Route), NULL, Object(Zend\\Stratigility\\Http\\Request), Object(Zend\\Stratigility\\Http\\Response), Object(Zend\\Stratigility\\Next))\n#41 /home/witple/public_html/vendor/flarum/core/src/Api/Middleware/FakeHttpMethods.php(32): Zend\\Stratigility\\Next->__invoke(Object(Zend\\Stratigility\\Http\\Request), Object(Zend\\Stratigility\\Http\\Response))\n#42 /home/witple/public_html/vendor/zendframework/zend-stratigility/src/Dispatch.php(224): Flarum\\Api\\Middleware\\FakeHttpMethods->__invoke(Object(Zend\\Stratigility\\Http\\Request), Object(Zend\\Stratigility\\Http\\Response), Object(Zend\\Stratigility\\Next))\n#43 /home/witple/public_html/vendor/zendframework/zend-stratigility/src/Dispatch.php(88): Zend\\Stratigility\\Dispatch->dispatchCallableMiddleware(Object(Flarum\\Api\\Middleware\\FakeHttpMethods), Object(Zend\\Stratigility\\Next), Object(Zend\\Stratigility\\Http\\Request), Object(Zend\\Stratigility\\Http\\Response), NULL)\n#44 /home/witple/public_html/vendor/zendframework/zend-stratigility/src/Next.php(160): Zend\\Stratigility\\Dispatch->__invoke(Object(Zend\\Stratigility\\Route), NULL, Object(Zend\\Stratigility\\Http\\Request), Object(Zend\\Stratigility\\Http\\Response), Object(Zend\\Stratigility\\Next))\n#45 /home/witple/public_html/vendor/flarum/core/src/Http/Middleware/ParseJsonBody.php(30): Zend\\Stratigility\\Next->__invoke(Object(Zend\\Stratigility\\Http\\Request), Object(Zend\\Stratigility\\Http\\Response))\n#46 /home/witple/public_html/vendor/zendframework/zend-stratigility/src/Dispatch.php(224): Flarum\\Http\\Middleware\\ParseJsonBody->__invoke(Object(Zend\\Stratigility\\Http\\Request), Object(Zend\\Stratigility\\Http\\Response), Object(Zend\\Stratigility\\Next))\n#47 /home/witple/public_html/vendor/zendframework/zend-stratigility/src/Dispatch.php(88): Zend\\Stratigility\\Dispatch->dispatchCallableMiddleware(Object(Flarum\\Http\\Middleware\\ParseJsonBody), Object(Zend\\Stratigility\\Next), Object(Zend\\Stratigility\\Http\\Request), Object(Zend\\Stratigility\\Http\\Response), NULL)\n#48 /home/witple/public_html/vendor/zendframework/zend-stratigility/src/Next.php(160): Zend\\Stratigility\\Dispatch->__invoke(Object(Zend\\Stratigility\\Route), NULL, Object(Zend\\Stratigility\\Http\\Request), Object(Zend\\Stratigility\\Http\\Response), Object(Zend\\Stratigility\\Next))\n#49 /home/witple/public_html/vendor/zendframework/zend-stratigility/src/MiddlewarePipe.php(111): Zend\\Stratigility\\Next->__invoke(Object(Zend\\Stratigility\\Http\\Request), Object(Zend\\Stratigility\\Http\\Response))\n#50 /home/witple/public_html/vendor/flarum/core/src/Http/AbstractServer.php(53): Zend\\Stratigility\\MiddlewarePipe->__invoke(Object(Zend\\Stratigility\\Http\\Request), Object(Zend\\Stratigility\\Http\\Response), NULL)\n#51 /home/witple/public_html/vendor/zendframework/zend-diactoros/src/Server.php(166): Flarum\\Http\\AbstractServer->__invoke(Object(Zend\\Diactoros\\ServerRequest), Object(Zend\\Diactoros\\Response), NULL)\n#52 /home/witple/public_html/vendor/flarum/core/src/Http/AbstractServer.php(34): Zend\\Diactoros\\Server->listen()\n#53 /home/witple/public_html/api.php(16): Flarum\\Http\\AbstractServer->listen()\n#54 {main}"
                }
              ]
            }

            Can you check it?

              wowmac 2017-01-30/08:22:070-.jpeg

              That's exactly what I was afraid of, the in-built file name generator I was using is replacing any invalid characters.. Just to make sure we don't get any disk persistence issues. I'll have to investigate this. Perhaps I should simply replace the filename with a unique hash.

                luceos

                I understand the error message.
                For the time being, I need to write about this issue.
                Thank you.

                Finrod disable and enable any extension, might as well do that on flarum-ext-english ? Also it might be the case that your language is not supported, I'm not sure it does a fallback on English (it should though).

                Finrod I often find that a hard refresh of my browser will fix that, too.

                Hello, I'm having some problems with my installation of this plugin.

                This keeps showing up whenever I try and upload an image.

                alt text
                When I click on the debug button, it shows an internal server error.

                I've tried modifying the php upload settings in php.ini, but I don't think it has anything to do with the error.

                Can anyone please help?

                  luceos First one is an "Oops, something went wrong, reload" error. The debug window is the second image, which reads:

                  500
                  
                  POST https://forums.estinet.net/api/flagrow/upload
                  
                  PHP Warning:   fopen(C:\Forums\assets/files\2017-02-02/00:52:010-chicken.jpeg): failed to open stream: 
                  Invalid argument in C:\Forums\vendor\league\flysystem\src\Adapter\Local.php on line 151

                  espidev wowmac

                  Released 0.4.5, which fixes;

                  • possibly the issues on windows systems, I can't safely test this, please send feedback
                  • issues with multiple uploads of files with foreign file names

                    Heyo!

                    I love the extension, but the issue is that when I use Imgur for uploading, the http:// variant is inserted instead of the https:// one. I understand some sites may use HTTPS (even though they shouldn’t), but then isn’t it possible to just insert //? That way, the browser tries to grab the HTTPS variant if available. If it’s not available, the non-HTTPS version is loaded.

                    Am I missing something here? This seems like a pretty obvious downside of the plugin. ?

                      CallMeMantas That way, the browser tries to grab the HTTPS variant if available. If it’s not available, the non-HTTPS version is loaded.

                      That's not the way this works. Using links with // will load the file from http if the current page is loaded with http. If the protocol is https, it's loaded using https. Hence there is no such magic fallback to http.

                      Nevertheless your suggestion is better than the one requesting to force https everywhere.

                        luceos Oh, sorry. I didn’t know that! Nevertheless, that solution still seems acceptable to me.

                          5 days later

                          Please, can you provide a MIME type code for enable uploading of Microsoft Office .docx files?

                          Mime Checker (http://mime.ritey.com) shows "application/vnd.openxmlformats-officedocument.wordprocessingml.document".

                            Ranger

                            application\/vnd\.openxmlformats-officedocument\.wordprocessingml\.document
                            5 days later

                            Hello luceos, thank you for providing this extension !

                            It worked great with me when I first tried it, but recently I have an issue.
                            When starting a discussion and uploading a picture, I get a message "resource not found". However, when looking into the folder assets/files/, my file has correctly been uploaded.
                            Would you know how to fix this ?

                            Thanks

                              Giyomu not really I'll try to reproduce your issue locally. If you have more information feel free to provide it.

                                luceos Thanks for your quick follow-up, I'll post mmore info when I have access to my server.

                                Hi

                                I have a problem installing this extension.
                                Im using Windows 7 and have installed XAMPP with apache and MySql.

                                Tested with Chrome and Firefox, the result is the same.

                                POST http://localhost:8080/api/flagrow/upload
                                
                                <br />
                                <b>Warning</b>:  array_map(): An error occurred while invoking the map callback in <b>C:\xampp\htdocs\UAVmatrix\vendor\illuminate\support\Collection.php</b> on line <b>469</b><br />
                                {"errors":[{"code":500,"title":"Internal server error","detail":"exception \u0027GuzzleHttp\\Exception\\RequestException\u0027 with message \u0027cURL error 60: SSL certificate problem: unable to get local issuer certificate (see http:\/\/curl.haxx.se\/libcurl\/c\/libcurl-errors.html)\u0027 in C:\\xampp\\htdocs\\UAVmatrix\\vendor\\guzzlehttp\\guzzle\\src\\Handler\\CurlFactory.php:187\nStack trace:\n#0 C:\\xampp\\htdocs\\UAVmatrix\\vendor\\guzzlehttp\\guzzle\\src\\Handler\\CurlFactory.php(150): 

                                I then tried to install certificates as described in this post http://stackoverflow.com/a/27667149
                                I now get permission error.

                                POST http://localhost:8080/api/flagrow/upload
                                
                                <b>Warning</b>:  array_map(): An error occurred while invoking the map callback in <b>C:\xampp\htdocs\UAVmatrix\vendor\illuminate\support\Collection.php</b> on line <b>469</b><br />
                                {"errors":[{"code":500,"title":"Internal server error","detail":"exception \u0027GuzzleHttp\\Exception\\ClientException\u0027 with message \u0027Client error: `POST https:\/\/api.imgur.com\/3\/upload` resulted in a `403 Permission Denied` response:\n{\u0022data\u0022:{\u0022error\u0022:\u0022Invalid client_id\u0022,\u0022request\u0022:\u0022\\\/3\\\/upload\u0022,\u0022method\u0022:\u0022POST\u0022},\u0022success\u0022:false,\u0022status\u0022:403}\n\u0027 in C:\\xampp\\htdocs\\UAVmatrix\\vendor\\guzzlehttp\\guzzle\\src\\Exception\\RequestException.php:111\nStack trace:\n#0 C:\\xampp\\htdocs\\UAVmatrix\\vendor\\guzzlehttp\\guzzle\\src\\Middleware.php(65): GuzzleHttp\\Exception\\RequestException::create(Object(GuzzleHttp\\Psr7\\Request), Object(GuzzleHttp\\Psr7\\Response))\n#1 

                                Any advice is much appreciated.

                                Edit #1
                                After some troubleshooting, i now get same result as @espidev

                                espidev Hello, I'm having some problems with my installation of this plugin.

                                This keeps showing up whenever I try and upload an image.

                                When I click on the debug button, it shows an internal server error.
                                I've tried modifying the php upload settings in php.ini, but I don't think it has anything to do with the error.
                                Can anyone please help?

                                Did a test run on my unix web server, and everything is working fine there.. ?
                                This is a great extension, thank you.

                                10 days later

                                I add ^audio\/.* to avaiable MIME type. When upload .mp3 file its extension becomes to .mpga

                                Also can you implement auto convert for image/audio files to html image/audio element ?

                                extension version: 0.4.6
                                flarum version: beta6