亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

如何在流明中顯示來自/storage/app/public 的圖像?

如何在流明中顯示來自/storage/app/public 的圖像?

PHP
富國滬深 2023-07-21 15:52:20
我從 API 得到了 JSON 格式的響應,其中包含內容文件名、創建時間、user_id 和 URL。所以我想通過將 URL 放入 來顯示前端響應中的圖像<img src={props.generated} alt="image"/>。我的前端代碼沒有任何問題,但沒有顯示圖像。這是我的響應中的圖像 URLhttp://localhost:8000/storage/public/user_3/1594265090.jpeg當我訪問 URL 時,這里是瀏覽器中的響應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,我確信它會發生,因為目錄的位置。我已經在嘗試執行命令mklink /D "./storage/app/public" "./public/storage"并收到響應Cannot create a file when that file already exists.
查看完整描述

1 回答

?
HUWWW

TA貢獻1874條經驗 獲得超12個贊

我正在使用ln -rs ./storage/app/public ./public/storage. 但這個命令是Linux的,所以我git bash在我的項目目錄中使用并執行這個命令。

結果解決了,可以訪問圖片了。


查看完整回答
反對 回復 2023-07-21
  • 1 回答
  • 0 關注
  • 129 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號