Fake a file upload with defined mimetype

Posted 8 months ago by Zini


I want to fake the upload of multiple types. It works for images, but I have a hard time finding out how to simulate other types of files.

Any not-image file gets inode/x-empty for mimetype, where I would like to see application/pdf.

// Mimetype ok
$file = \Illuminate\Http\UploadedFile::fake()->image('test.jpg');

// Mimetype issue: inode/x-empty
$file = \Illuminate\Http\UploadedFile::fake()->create('test.pdf');

// also tried this
$file->mimeType = 'application/pdf';

I did not find yet any solution in the Illuminate doc, or the Symfony doc.

Please sign in or create an account to participate in this conversation.

Reply to

Use Markdown with GitHub-flavored code blocks.