douwu5428
2017-07-05 06:34
浏览 133
已采纳

无法打开流:Laravel 5.4中的权限被拒绝甚至Al文件权限也被授予使用Laravel 5.4中的存储功能的路径

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

</div>

图片转代码服务由CSDN问答提供 功能建议

我正在尝试将文件上传到C:\ Users \ sandeep \ maxo \ storage \ app \ public文件夹中 laravel 5.4。 我使用下面的代码

 &lt;!DOCTYPE  html&gt; 
 
&lt; html&gt; 
 
&lt; head&gt; 
 
&lt; title&gt;&lt; / title&gt; 
 
&lt; / head&gt; 
 
&lt; body&gt; 
 
  
&lt; form action =“{{URL :: to('importExcelFile')}}”class =“form-horizo​​ntal”method =“post”enctype =“multipart / form-data”&gt; 
 
&lt;  ; input type =“file”name =“import_file”/&gt; 
 
 {{csrf_field()}} 
 
&lt; br /&gt; 
 
&lt; button&gt;导入CSV或Excel文件&lt;  ; / button&gt; 
 
&lt; / form&gt; 
 
&lt; / body&gt; 
 
&lt; / html&gt;   
 
  
 \  n  
 
 
 
 

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

是laravel代码。

但是我收到了像你这样的错误 s

fopen(C:\ Users \ sandeep \ maxo \ storage \ app \ public / K4oIHMXveyx2VChmAXAcNkTmoIXKACvqoIbbHCeB。):无法打开流:权限被拒绝 \ n

这是我的错误图片 请点击 这里

但是当我上传图片时工作正常

  • 写回答
  • 好问题 提建议
  • 关注问题
  • 收藏
  • 邀请回答

2条回答 默认 最新

  • donglou1866 2017-07-05 09:58
    已采纳

    Try on terminal sudo chmod -R 777 public it will change the directory permission

    已采纳该答案
    评论
    解决 无用
    打赏 举报
  • dongsanhu4784 2018-06-22 09:22

    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

    评论
    解决 无用
    打赏 举报