Abhi324's avatar

Laravel file vs Storage

My first question . Which one is more efficient / stable to use ?

2nd . I got the file working fine with images and its saving it properly in my folder

$upload = $file->move($destination, $name); 

However with storage , it is saving an invalid file in that folder . No idea why .

$file= $request->file('img');
$ext = $file->getClientOriginalExtension(); 
$name="yyy".".".$ext;

Storage::disk('image')->put($name, $file);

The name & extension is correct but the file being saved cannot be opened. I can see the file in that folder but it seems corrupt / not an image

0 likes
1 reply
Abhi324's avatar
Abhi324
OP
Best Answer
Level 1

Solved

Storage::disk('image')->put($name, file_get_contents($file));

Question still remains tho - is this more efficient , better than file move ?

Please or to participate in this conversation.