我有一个应用程序,用户可以在其中上传图片文件。我使用 s3 进行存储。在我的本地计算机上,这工作正常,但是当我部署到 Heroku 时,每次我尝试上传(通过单击应用程序中的表单按钮)时,都会收到一条错误消息,提示““”文件不存在或不可读”。它在这行代码上崩溃:$path = Storage::disk('s3')->put('images/profile', request('image'));问题似乎出在 put 方法的输入上。我在该行代码之前根据 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}我猜这是某种文件系统权限问题,但欢迎提出想法。
2 回答
陪伴而非守候
TA贡献1757条经验 获得超8个赞
尝试此解决方案(.user.ini)
如果它不起作用:
让我们
nginx.conf
在根目录中创建并添加以下内容:
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 关注
- 118 浏览
添加回答
举报
0/150
提交
取消