Home > Software design >  Laravel upload and validate apk file
Laravel upload and validate apk file

Time:12-12

I need to upload an apk file into my laravel application and i have this rule for request validation but getting invalid data type error when uploading an apk file.

        return [
        'app'=>'required|mimes:application/vnd.android.package-archive,apk'
    ];

CodePudding user response:

There is no need to specify mimes with apk.

return [
        'app'=>'required|mimes:application/vnd.android.package-archive'
    ];

or go with root functionality

'app' => Illuminate\Http\UploadedFile::__set_state(array(
     'test' => false,
     'originalName' => 'QuickDrive.apk',
     'mimeType' => 'application/vnd.android.package-archive',
     'size' => 95585970,
     'error' => 0,
     'hashName' => NULL,
  )),

CodePudding user response:

Don't need to append apk, use the following code snippet

return ['app'=>'required|mimes:application/vnd.android.package-archive'];

See Laravel Doc, and Full listing of MIME types

  • Related