Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

towerful's avatar

Filesystem (uploads) and PHP Resource to '::put'

So, the 5.1 docs ( http://laravel.com/docs/5.1/filesystem#storing-files ) describing using a PHP resource for managing large files.

If a User is uploading a large file, how do I make sure that is a resource?
Do I just pass in $request->file('my-large-upload')? or is there more to that?

I'm pretty new to file uploading/file-management in laravel, and (unfortunately) resource is quite a common google keyword :|

0 likes
1 reply
jespejo89's avatar

A bit late to this, but I came across the same problem and actually the solution is as easy as creating a Resource out of the content of the file that you want to upload.

For instance, if you want to "put" a file directly from an user upload, you'd something like this:

$userUpload = $request->file('file');
$resource = fopen( $userUpload->getRealPath(), 'r');
Storage::put(  'path/to/save/the/file.ext', $resource );

I hope this clarifies your doubts.

Cheers! Jesús E.

3 likes

Please or to participate in this conversation.