我有一個應用程序,用戶可以在其中上傳圖片文件。我使用 s3 進行存儲。在我的本地計算機上,這工作正常,但是當我部署到 Heroku 時,每次我嘗試上傳(通過單擊應用程序中的表單按鈕)時,都會收到一條錯誤消息,提示““”文件不存在或不可讀”。它在這行代碼上崩潰:$path = Storage::disk('s3')->put('images/profile', request('image'));問題似乎出在 put 方法的輸入上。我在該行代碼之前根據(jù) request('image') 進行了轉儲并死亡。在我的本地副本上,我看到的是:Illuminate\Http\UploadedFile {#1236 ▼ -test: false -originalName: "gary-bendig-6GMq7AGxNbE-unsplash.jpg" -mimeType: "image/jpeg" -error: 0 #hashName: null path: "C:\xampp\tmp" filename: "phpD90.tmp" basename: "phpD90.tmp" pathname: "C:\xampp\tmp\phpD90.tmp" extension: "tmp" realPath: "C:\xampp\tmp\phpD90.tmp" aTime: 2020-06-30 20:09:05 mTime: 2020-06-30 20:09:05 cTime: 2020-06-30 20:09:05 inode: 5629499534269665 size: 2328835 perms: 0100666 owner: 0 group: 0 type: "file" writable: true readable: true executable: false file: true dir: false link: false linkTarget: "C:\xampp\tmp\phpD90.tmp"}這是我在 Heroku 上看到的:^ Illuminate\Http\UploadedFile {#1168 ▼ -test: false -originalName: "gary-bendig-6GMq7AGxNbE-unsplash.jpg" -mimeType: "application/octet-stream" -error: 1 #hashName: null path: "" filename: "" basename: "" pathname: "" extension: "" realPath: "/app/public" aTime: 1970-01-01 00:00:00 mTime: 1970-01-01 00:00:00 cTime: 1970-01-01 00:00:00 inode: false size: false perms: 00 owner: false group: false type: false writable: false readable: false executable: false file: false dir: false link: false}我猜這是某種文件系統(tǒng)權限問題,但歡迎提出想法。
2 回答

陪伴而非守候
TA貢獻1757條經(jīng)驗 獲得超8個贊
嘗試此解決方案(.user.ini)
如果它不起作用:
讓我們
nginx.conf
在根目錄中創(chuàng)建并添加以下內容:
client_max_body_size 25M;
location / {
? ? # try to serve file directly, fallback to rewrite
? ? try_files $uri @rewriteapp;
}
location @rewriteapp {
? ? # rewrite all to index.php
? ? rewrite ^(.*)$ /index.php/$1 last;
}
location ~ ^/index\.php(/|$) {
? ? try_files @heroku-fcgi @heroku-fcgi;
? ? # ensure that /index.php isn't accessible directly, but only through a rewrite
? ? internal;
}
將Procfile內容設置為:
web: vendor/bin/heroku-php-nginx -C nginx.conf public/
重新部署 Heroku 應用程序
- 2 回答
- 0 關注
- 165 瀏覽
添加回答
舉報
0/150
提交
取消