Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Failed to open stream: Permission denied in Laravel 5.4 Even Al File Permission are granted to the path using Store Function in Laravel 5.4

Tags:

php

laravel

I am trying to upload a file into C:\Users\sandeep\maxo\storage\app\public folder in laravel 5.4. I am using the below code

    <!DOCTYPE html>
    <html>
        <head>
            <title></title>
        </head>
        <body>
            <form  action="{{ URL::to('importExcelFile') }}" class="form-horizontal" method="post" enctype="multipart/form-data">
                <input type="file" name="import_file" />
                {{ csrf_field() }}
                <br/>
                <button >Import CSV or Excel File</button>
            </form>
        </body>
    </html>

$path = $request->file('import_file')->store('public');

is the laravel code.

But I am getting an error like this

fopen(C:\Users\sandeep\maxo\storage\app\public/K4oIHMXveyx2VChmAXAcNkTmoIXKACvqoIbbHCeB.): failed to open stream: Permission denied

This is the picture of my error Click here

But When i Upload the image its working fine

like image 850
Sandeep Garapati Avatar asked Jul 05 '17 06:07

Sandeep Garapati


1 Answers

As has been stated everywhere, you better not give 777 permissions, its a security risk. Instead just use

sudo chown -R www-data:www-data storage

if you are using apache, it will give permission to the apache's user

like image 138
Muhammad Ibnuh Avatar answered Nov 14 '22 01:11

Muhammad Ibnuh