0

After some days to trace why I get The connection was reset error on created upload form on Laravel I thought the problem is on the server and I change more options of apache2 but nothing changed.

I created simple PHP for upload file like with below implementation, that's work!!. now whats problem on my upload form on Laravel implementation which I get this error or timeout?

Please keep in the mind: I don't have any problem to upload small size files

Laravel implementation:

form:

<form action="{{route('lessons.store')}}" method="POST" enctype="multipart/form-data">
    {{ csrf_field() }}
    <div class="form-group">
        <div class="form-group">

        <div class="form-group">
            <label class="display-block">please choose file</label>
            <div class="media no-margin-top">
                <div class="media-body">
                    <input type="file" class="file-styled" name="file"
                           value="{{old('file')}}">
                </div>
            </div>
        </div>

        <div class="text-right">
             <button type="submit" class="btn btn-primary">Upload FILE
                    <i class="icon-arrow-left13 position-right"></i></button>
        </div>
</form>

controller:

public function store(RequestContents $request)
{
    ini_set('memory_limit', '256M');
    $uploadedFile = $request->file('file');

    dd($uploadedFile);
}

route:

Route::group(['namespace' => 'Dashboard', 'middleware' => ['auth:web'], 'prefix' => 'panel'], function () {
    ...
    $this->resource('lessons', 'LessonsController');
    ...
});
3
  • When uploading large files always use stream to upload file as it will not overload you server. blog.larapulse.com/laravel/handling-large-files-on-s3 Commented May 16, 2019 at 6:25
  • @SalmanZafar so how about upload file into public_html instead of using disk? Commented May 16, 2019 at 6:41
  • still use stream to upload your file on your server or on some other FTP as all the load will be on your server when you uploading in directly either on disk or on public_html Commented May 16, 2019 at 6:47

2 Answers 2

2

Please try again after removing enctype="multipart/form-data" attribute from the form.

Sign up to request clarification or add additional context in comments.

2 Comments

i get null after uploading file
Try adding these to your code:ini_set('upload_max_filesize','50M') and ini_set('post_max_size','50M')
1

For uploading a very large file to server cause many problems like server resource occupied while upload network conditions. I've faced similar kind of problem while uploading a large file ( 30+ GB size ).

I've used this approach,

In front end side I used Dropzone.js Resumable.js very promising. Rather than uploading the whole file directly to a server, it'll upload in a small chunk ( 10 MB ) and also manage file parts and other things.

In backend side in your case Laravel, we've used pionl/laravel-chunk-upload which is compatible with the above mentioned both uploader. It'll manage all sort of management of file chunks, last chunk, and stitching for you.

Using this combination will handle all sort of large file for you there're other parameters in the library which you can play with like chunk size and whether to use resumable file upload or not.

EDIT

If you're using S3 or any other Object Storage Service try to upload directly to them it'll save your cost.

If you need any further help feel free to ask.

2 Comments

i implemented your solution but for small files i don't have problem with DropZone but i can't upload large file for example 15MG, i dont get any error on console,
Check if it's uploading in chunk or not?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.