I have an app where the user can upload a picture file. I use s3 for storage. On my local machine this works fine but when I deploy to Heroku, every time I try to upload (by clicking a form button in my app) I get an error saying ‘The “” file does not exist or is not readable’. It crashes on this line of code:
JavaScript
x
$path = Storage::disk('s3')->put('images/profile', request('image'));
The problem seems to lie with the put method inputs. I did a dump and die on request(‘image’) right before that line of code. On my local copy here’s what I see:
JavaScript
IlluminateHttpUploadedFile {#1236 ▼
-test: false
-originalName: "gary-bendig-6GMq7AGxNbE-unsplash.jpg"
-mimeType: "image/jpeg"
-error: 0
#hashName: null
path: "C:xampptmp"
filename: "phpD90.tmp"
basename: "phpD90.tmp"
pathname: "C:xampptmpphpD90.tmp"
extension: "tmp"
realPath: "C:xampptmpphpD90.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:xampptmpphpD90.tmp"
}
Here’s what I see on Heroku:
JavaScript
^ IlluminateHttpUploadedFile {#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
}
I’m guessing it’s some kind of file system permission problem but open to ideas.
Advertisement
Answer
Turns out that uploading pics <2MB worked. Maybe it’s a setting in php.ini but not sure how to edit that on Heroku