Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/242.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 拉雷维尔5元';t从存储部分删除文件_Php_Laravel_Laravel 5_Laravel 5.2 - Fatal编程技术网

Php 拉雷维尔5元';t从存储部分删除文件

Php 拉雷维尔5元';t从存储部分删除文件,php,laravel,laravel-5,laravel-5.2,Php,Laravel,Laravel 5,Laravel 5.2,当我试图通过控制器删除特定文件时,我得到一个错误 很抱歉,找不到您要查找的页面。 NotFoundHttpException 这是我的控制器: public function destroyFile($file_name) { $file = storage_path('documents').'/'.$file_name; Storage::delete($file); return redirect('/documents'); } 我的路线: Route::d

当我试图通过控制器删除特定文件时,我得到一个错误

很抱歉,找不到您要查找的页面。 NotFoundHttpException

这是我的控制器:

public function destroyFile($file_name)
{
    $file = storage_path('documents').'/'.$file_name;
    Storage::delete($file);
    return redirect('/documents');
}
我的路线:

  Route::delete('documents/{file}','FilesController@destroyFile');
我的看法是:

    {!! Form::open(['method' => 'DELETE', 'action' =>     ['FilesController@destroyFile', $file->name] ]) !!}
                            {!! Form::hidden('_method', 'DELETE') !!}
                            {!! Form::token() !!}
                            {!! Form::submit(trans('buttons.del-cat'),['class'=>'btn btn-danger user-delete push-right']) !!}
                            {!! Form::close() !!}

我也有同样的问题,一切都安排好了,但还是不起作用

我用了
File::delete()
而不是
Storage::delete()
,这就解决了它


希望这能奏效

我也遇到了同样的问题,一切都安排好了,但仍然不起作用

public function images(Request $request,$id){
    $user_id=$request->session()->get('user_id');
    $data=DB::table('company_images')->where('id',$id)->first();
    //deleteing the image from database and server
    DB::table('company_images')->where('id', '=', $id)->delete();
    //delete the image form the server
    $path=public_path("/assets/img/company/$data->image");
    unlink($path);
    return redirect("/company/$user_id/add_details")->with('delete','delete');

}
我用了
File::delete()
而不是
Storage::delete()
,这就解决了它

希望这能奏效

public function images(Request $request,$id){
    $user_id=$request->session()->get('user_id');
    $data=DB::table('company_images')->where('id',$id)->first();
    //deleteing the image from database and server
    DB::table('company_images')->where('id', '=', $id)->delete();
    //delete the image form the server
    $path=public_path("/assets/img/company/$data->image");
    unlink($path);
    return redirect("/company/$user_id/add_details")->with('delete','delete');

}
这是我用来使用unlink($path)删除公司图片的功能。这对我来说很好。还有一个重要的提示:你应该仔细写下你删除的文件的路径


这是我用来使用unlink($path)删除公司图片的功能。这对我来说很好。还有一个重要的提示:你应该仔细写下你删除的文件的路径

必须在
filesystem.php
中设置
public

'default'=>env('FILESYSTEM\u DRIVER','public')

而不是:

'default'=>env('FILESYSTEM\u DRIVER','local')


local
更改为
public
您必须在
filesystem.php中设置
public

'default'=>env('FILESYSTEM\u DRIVER','public')

而不是:

'default'=>env('FILESYSTEM\u DRIVER','local')


local
更改为
public

哪个请求失败…删除到/documents/{file}或重定向到/documents?重定向失败,但仍然没有删除存储中的文件在调用
Storage::DELETE($file)
时,$file的计算结果是什么?该文件是否确实存在于指定的路径上?exist($file)表示fals,但该路径中有一个类似的文件听起来好像没有文件…请仔细检查配置、路径和扩展名以及所有内容。哪个请求失败…删除/documents/{file}或者重定向到/documents?重定向失败,但仍无法删除存储中的文件在调用
Storage::delete($file)
时,$file的计算结果是什么?该文件是否确实存在于指定的路径上?exist($file)表示fals,但该路径中有一个类似的文件。听起来那里没有文件……请仔细检查配置、路径和扩展名以及所有内容。