我從 API 得到了 JSON 格式的響應(yīng),其中包含內(nèi)容文件名、創(chuàng)建時間、user_id 和 URL。所以我想通過將 URL 放入 來顯示前端響應(yīng)中的圖像<img src={props.generated} alt="image"/>。我的前端代碼沒有任何問題,但沒有顯示圖像。這是我的響應(yīng)中的圖像 URLhttp://localhost:8000/storage/public/user_3/1594265090.jpeg當(dāng)我訪問 URL 時,這里是瀏覽器中的響應(yīng)The requested resource /storage/public/user_3/1594265090.jpeg was not found on this server.這是我的代碼 $response = $this->client->request('POST', 'API', $data); $image = $response->getBody()->getContents(); $filePath = 'public/' . $this->getUserDir(); $fileName = time().'.jpeg'; if ($result = Storage::put($filePath . '/' . $fileName, $image)) { $generated = $model::create([ 'name' => $fileName, 'file_path' => $filePath, 'type' => 'motif', 'customer_id' => Auth::id() ]); return response($generated);放入圖像/storage/app/public,我確信它會發(fā)生,因為目錄的位置。我已經(jīng)在嘗試執(zhí)行命令mklink /D "./storage/app/public" "./public/storage"并收到響應(yīng)Cannot create a file when that file already exists.
1 回答

HUWWW
TA貢獻(xiàn)1874條經(jīng)驗 獲得超12個贊
我正在使用ln -rs ./storage/app/public ./public/storage
. 但這個命令是Linux的,所以我git bash
在我的項目目錄中使用并執(zhí)行這個命令。
結(jié)果解決了,可以訪問圖片了。
- 1 回答
- 0 關(guān)注
- 126 瀏覽
添加回答
舉報
0/150
提交
取消