我想通過命令列運行此代碼:
public function handle()
{
if ( ! File::exists(storage_path('/app/public/examResult/' . $this->argument('file'))) ) {
dd('Not found this file!');
}
Excel::import(new ImportsExamResultImport(), storage_path('/app/public/examResult/' . $this->argument('file')));
dd('Import excel was successfully');
}
所以它基本上讀取位于storage_path('/app/public/examResult/')目錄中的 Excel 檔案。
所以我把我的 Excel 檔案放在了,laravelproject/app/public/examResult但是當我運行命令來執行它時,我收到了這條訊息:
沒有找到這個檔案!
那么問題來了,究竟在哪里storage_path?我是否將檔案放在正確的位置?
uj5u.com熱心網友回復:
當您設定一個新專案時,您需要運行:
php artisan storage:link
這建立了從 laravelproject/public/storage 到 laravelproject/storage 的符號鏈接
storage_path('/app/public')
可以在以下位置找到:
laravelproject/storage/app/public
轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/312825.html
標籤:php 拉拉维尔 laravel-5.8
上一篇:Laravel超級選單回圈
