karwanjacksi's avatar

Problems with PDF uploading Laravel 5

Hello!

I have an application based on Laravel 5 with file upload functionality. Everything works fine except uploading of some PDF files.

The applications can not upload some of PDF files, and when I try to open them, they seems normal like any other PDF files. Any idea how to solve this problem?

 dd($request);  //MyRequest $request

// Here is the part of dd($request) related to file

 +files: FileBag {#244 ▼
    #parameters: array:1 [▼
      "file" => UploadedFile {#27 ▼
        -test: false
        -originalName: "111.pdf"
        -mimeType: "application/octet-stream"
        -size: 0
        -error: 1
      }]}

//Here is my request rules
 return ['file'  =>  'mimes:pdf|max:10000',

While for other PDF files are just working fine like bellow dd($request)

+files: FileBag {#244 ▼
    #parameters: array:1 [▼
      "file" => UploadedFile {#27 ▼
        -test: false
        -originalName: "cv.pdf"
        -mimeType: "application/pdf"
        -size: 28141
        -error: 0
      }]}
0 likes
3 replies
sid405's avatar

@karwanjacksi Few questions for a preliminary checklist

  • Are you getting any errors?
  • Are you printing your validation errors from the request?
  • Are you noticing the files you cannot upload are above a certain size?
  • If so, what's the upload limit and max request limit on your php.ini?
1 like
karwanjacksi's avatar

upload limit in php.ini was the problem ;)

Thank you guys!

2 likes

Please or to participate in this conversation.