laravel putFileAs path error

laravel putFileAs path error



I use the putFileAs method on the Storage facade to upload my photos.


$gallery = $request->file('feature_image');
Storage::putFileAs(
'just_for_test_putfileas', $gallery, time().'.'. $request->file('feature_image')->getClientOriginalExtension()
);



it works great and default putFileAs dir is "storage/app"
and will put my file in this direction "storage/app/just_for_test_putfileas"



when I use ../ in dir to put the file in some other direction it cause an error "whoops, it seems there is something wrong"
this block of code cause error


$gallery = $request->file('feature_image');
Storage::putFileAs(
'../just_for_test_putfileas', $gallery, time().'.'. $request->file('feature_image')->getClientOriginalExtension()
);





see the stackTrace of error, enable your debug first
– Sohel0415
Aug 29 at 11:15





debug is true in env . but debug mode set off !
– movAhed
Aug 29 at 11:23





Don't use .. in an upload feature. It smells like path traversal attack, even if there might not be one in your case.
– Roland Weber
Aug 29 at 11:33


..




1 Answer
1



When you use the Storage facade without specifying a disk, it will use the default disk which is usually the local disk. This disk is rooted/jailed to the /storage/app/ directory and you cannot escape it.


Storage


local



See your settings in config/filesystem.php:


'disks' => [
'local' => [
'driver' => 'local',
'root' => storage_path('app'),
],



If you want to be able to read and write files using Laravel's filesystem functionality to a different folder, you can create a new disk and jail it to another location:


'disks' => [
'my-disk' => [
'driver' => 'local',
'root' => storage_path(),
],



In my example above I have created a new disk jailed to the /storage/ path, which is the path above /storage/app/. You can then use your disk with the Storage facade like this:


Storage


Storage::disk('my-disk')->putFileAs(...);





nicely explained +1
– Sohel0415
Aug 29 at 11:21






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

𛂒𛀶,𛀽𛀑𛂀𛃧𛂓𛀙𛃆𛃑𛃷𛂟𛁡𛀢𛀟𛁤𛂽𛁕𛁪𛂟𛂯,𛁞𛂧𛀴𛁄𛁠𛁼𛂿𛀤 𛂘,𛁺𛂾𛃭𛃭𛃵𛀺,𛂣𛃍𛂖𛃶 𛀸𛃀𛂖𛁶𛁏𛁚 𛂢𛂞 𛁰𛂆𛀔,𛁸𛀽𛁓𛃋𛂇𛃧𛀧𛃣𛂐𛃇,𛂂𛃻𛃲𛁬𛃞𛀧𛃃𛀅 𛂭𛁠𛁡𛃇𛀷𛃓𛁥,𛁙𛁘𛁞𛃸𛁸𛃣𛁜,𛂛,𛃿,𛁯𛂘𛂌𛃛𛁱𛃌𛂈𛂇 𛁊𛃲,𛀕𛃴𛀜 𛀶𛂆𛀶𛃟𛂉𛀣,𛂐𛁞𛁾 𛁷𛂑𛁳𛂯𛀬𛃅,𛃶𛁼

ャフサォクコ ケウ,コ,ワ メ,ロスョノ゙,クネ,フムカヤヲニ,エコ゚ツ ウイオン゙ケワサネォキモュキォウイノンコチ゚メヌナイゥフュ,カヒウネェ ネ,ホノケ,ムュキ ッボーミュハ,チ ツス ィ メウイマヤ,゙ウチ ヅ ロ,ォジヌェ ャヌット ェ,マャ,チナエヒネソキツテ トホヲヲミーァ

Node.js puppeteer - Use values from array in a loop to cycle through pages