Problem with uploading files, flow-php-server and Laravel
See original GitHub issueI ran into a problem of files not being uploaded today using flow-php-server together with Laravel. For me the problem was that the 404 header wasn’t properly returned on the test function of flow.js. Instead it would just return a 200 which in turn caused flow.js to not send the POST request after the GET request to check for the chunk existence.
In Laravel you should do something like this in the controller method that handles the flow.js requests. (taken from the basic example):
if (\Flow\Basic::save('./uploads/name_of_new_file', './chunks_temp_folder')) {
// file saved successfully and can be accessed at './final_file_destination'
} else {
// This is not a final chunk or request is invalid, continue to upload.
$response = Response::make('', 404);
return $response;
}
When I started I left the else block empty. Now the whole thing makes sense to me, but I haven’t done much backend before, so all in all this took me a couple of hours. I figured maybe posting this here helps someone else.
Issue Analytics
- State:
- Created 9 years ago
- Comments:11 (3 by maintainers)
Top Results From Across the Web
Why am I still getting this file-upload error in Laravel?
The key is that I'm using Axios to send the file to the server. This code properly returns the MIME type for all...
Read more >3 Helpful Tips For Doing Laravel File Uploads
Stuck with File upload? Laravel file upload is a PHP framework, and by using Filestack's PHP SDK you can find an easy solution!...
Read more >Request Lifecycle - Laravel - The PHP Framework For Web ...
Lifecycle Overview. First Steps. The entry point for all requests to a Laravel application is the public/index.php file. All requests ...
Read more >Plain PHP Resumable Large File Uploads in Chunks ... - Morioh
Code available at GitHub Php FlowJs Resumable File Upload ... Use the following composer command to install Flow PHP Server to handle the...
Read more >Test and deploy Laravel applications with GitLab CI/CD and ...
Create a Container Image ; # Install PHP and composer dependencies RUN apt-get install -qq ; # Clear out the local repository of...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I am not a laravel user, but the key tasks would be:
Response
class:You might also pass params to
Flow\Request
class https://github.com/flowjs/flow-php-server/blob/master/src/Flow/Request.php#L12 Or you can rewrite this class in a laravel way. I haven’t tested this, but it might work.Laravel way instead of
$_SERVER['REQUEST_METHOD'] === 'GET'
would beif ($request->isMethod('get')) { }
where $request isIlluminate\Http\Request
injected into method as Request $request