felipesmendes's avatar

Laravel Validation erro in uploading JPG image.

Hello people,

I'm making a form to upload photos, and when uploading a .JPG photo laravel shows how to return with the error:

The photo failed to upload

But when I try to upload a photo .PNG works normally

I noticed that the object returned by each file type is different, see:

.JPG

Illuminate\Http\UploadedFile {#963 ▼
  -test: false
  -originalName: "IMG_4852.jpg"
  -mimeType: "application/octet-stream"
  -error: 1
  #hashName: null
  path: ""
  filename: ""
  basename: ""
  pathname: ""
  extension: ""
  realPath: "C:\Users\felip\OneDrive\Documents\tracker2.0\public"
  aTime: 1969-12-31 21:00:00
  mTime: 1969-12-31 21:00:00
  cTime: 1969-12-31 21: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
}

.PNG

Illuminate\Http\UploadedFile {#963 ▼
  -test: false
  -originalName: "Icone app.png"
  -mimeType: "image/png"
  -error: 0
  #hashName: null
  path: "C:\Users\felip\AppData\Local\Temp"
  filename: "php56D3.tmp"
  basename: "php56D3.tmp"
  pathname: "C:\Users\felip\AppData\Local\Temp\php56D3.tmp"
  extension: "tmp"
  realPath: "C:\Users\felip\AppData\Local\Temp\php56D3.tmp"
  aTime: 2020-02-12 14:03:56
  mTime: 2020-02-12 14:03:56
  cTime: 2020-02-12 14:03:56
  inode: 0
  size: 57748
  perms: 0100666
  owner: 0
  group: 0
  type: "file"
  writable: true
  readable: true
  executable: false
  file: true
  dir: false
  link: false
  linkTarget: "C:\Users\felip\AppData\Local\Temp\php56D3.tmp"
}

The .JPG file path is empty and the required field validation says

The value is an uploaded file with no path.

How can I resolve this situation?

0 likes
4 replies
psylogic's avatar

@felipesmendes ,

Would you try to increase the post_max_size from 2mb to 8mb because the Image jpg when it exceeded 2mb it become octet-stream (I could be wrong)

Try it and let me know !

psylogic's avatar
psylogic
Best Answer
Level 7

Great, would you mark the thread as solved. Thanks!

felipesmendes's avatar

@psylogic Sorry, I was wrong, I took a picture from another device and it worked, but the error remains in pictures taken through the iphone.

I increased the post_max_size size to 100 mb

Please or to participate in this conversation.