File Path in project

Asked

Viewed 401 times

0

I have a project where I need to develop a billing request, I am implementing a spreadsheet import for DB Mysql, until this part is OK, the problem is that I can’t find the file inside the folder Log of the Laravel, I already applied the LINK command, is uploading, but I can’t get file to use after uploading, I’ve tried several ways with the path, several methods like Asset, url and some others, could tell me where I’m going wrong.

Follows method:

public function store(Request $request)
{
    if($request->hasFile('file_path') && $request->file('file_path')->isValid()) {

        $name = 'carteira-vendas';

        $extension = $request->file_path->extension();
        $nameFile = "{$name}.{$extension}";

        $upload = $request->file_path->storeAs('public/import-planilha', $nameFile);

        $rows = ImportCarteiraVendas::where("id", "like", "%%")->get();

        if(!is_null($rows)){
            DB::table('carteira_vendas_table')->delete();
        }

        Excel::import(new CartVendasImport, url("import-planilha/".$nameFile));

        Session::flash('import_cart_msg', "Importação efetuada com sucesso!");

        return redirect(action("ImportCarteiraVendasController@create"));
    }
}
  • What version of Laravel?

  • Laravel Framework 5.6.29

  • Try passing your request file to import. Ex: Excel::import(new CartVendasImport, $request->file('your_file'));

  • If it doesn’t work I think you can get your file this way: Storage::disk('local')->path($filename);

  • Sorry the delay in reply, but it worked out, thank you very much! put as a reply I give the OK..

1 answer

0

You can pass your request file to import from Excel.

Excel::import(new CartVendasImport, $request->file('your_file'));

Browser other questions tagged

You are not signed in. Login or sign up in order to post.