Welcome Guest, Not a member yet? Register   Sign In
Upload pdf file fails
#1

(This post was last modified: 09-01-2024, 06:59 AM by warcooft.)

I try upload file image and working fine, but why not work with pdf file?
i got error "The file requirement is not a valid uploaded file". whats wrong?

PHP Code:
$validationRule = [
            'file' => [
                'label' => 'File Upload',
                'rules' => [
                    'uploaded[file]',
                    'mime_in[file,application/pdf,application/force-download,application/x-download]',
                    'max_size[file,5120]',
                ],
            ],
        ];
        if (! $this->validate($validationRule)) {
            $errors $this->validator->getErrors();
            $error array_shift($errors);

            dd($error);
        

after dd($file = $this->request->getFile('file')); originalMimeType is empty string.

[Image: Screenshot-2024-09-01-at-20-55-54.png]
@xxxx[{::::::::::::::::::::::::::::::::>
Reply
#2

This issue has been resolved. It seems the file I tried to upload was broken, but I don’t know why that file can still be opened and read normally with a PDF reader like Preview in Mac.
@xxxx[{::::::::::::::::::::::::::::::::>
Reply




Theme © iAndrew 2016 - Forum software by © MyBB