theUnforgiven's avatar

Filesystem, S3 something not right

Hi all,

I have a basic upload form to upload mainly PDF files. If I upload a file at 87kb it only stores 630B on S3 for some reason like I'm missing something, but not sure as to what.

Here's the code I have to upload and store on S3.

$file = $request->file('file');
                $name = Str::random(35).'.'.$file->getClientOriginalExtension();

                $s3 = Storage::disk('s3');
                $s3->put(strtolower(user()->companies->first()->name).'/'.$name, $name, 'public');
                $path = Storage::disk('s3')->url(strtolower(user()->companies->first()->name).'/'.$name);
0 likes
6 replies
theUnforgiven's avatar

This is also my form:

<form action="{{ route('document.store') }}" method="post" class="form-horizontal" enctype="multipart/form-data">
            {{ csrf_field() }}
            <div class="modal-body">
                

                <div class="row" style="padding: 15px;">
                    <div class="form-group">
                        <div class="col-sm-2">Choose File</div>
                        <div class="col-lg-6">
                            <input type="file" name="file">
                        </div>
                    </div>
                </div>
                
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
                <button type="submit" class="btn btn-success">Save &amp; Upload</button>
            </div>
      </form>
theUnforgiven's avatar

anyone know what's wrong and why only a portion is been uploaded rather than the full file (size)

mcangueiro's avatar

I believe the method you wanna use for this is the store method.

Cronix's avatar
Cronix
Best Answer
Level 67

Actually it looks like you're using the ->put() method, not store.

I believe you're only storing the filename, and not the actual file, because you're trying to name the file a different name, which you can't do with put().

You need to use putFileAs or another one of the methods that allow you to specify the name of the saved file.

1 like

Please or to participate in this conversation.