strange, i've gone through the code just now, and it goes through:
- Illuminate\Http\UploadedFile
- Illuminate\Http\Testing\FileFactory
- Illuminate\Http\Testing\File
public static function from($filename)
{
$extension = pathinfo($filename, PATHINFO_EXTENSION);
return self::getMimeTypeFromExtension($extension);
}
protected static function getMimeTypeFromExtension($extension)
{
return self::$mimes[$extension] ?? 'application/octet-stream';
}
It should be getting the mimetype from the name you give, and pdf is in the list of extensions.
'pdf' => 'application/pdf',
Testing it myself:
$file = \Illuminate\Http\UploadedFile::fake()->create('test.pdf');
dd($file);
File {#403 ▼
+name: "test.pdf"
+tempFile: stream resource @13 ▶}
+sizeToReport: 0
-test: true
-originalName: "test.pdf"
-mimeType: "application/pdf"
-error: 0
#hashName: null
path: "/tmp"
filename: "phpREZVKB"
basename: "phpREZVKB"
pathname: "/tmp/phpREZVKB"
extension: ""
realPath: "/tmp/phpREZVKB"
aTime: 2018-07-11 20:50:45
mTime: 2018-07-11 20:50:45
cTime: 2018-07-11 20:50:45
inode: 3407925
size: 0
perms: 0100600
owner: 33
group: 33
type: "file"
writable: true
readable: true
executable: false
file: true
dir: false
link: false
}
What version of laravel are you on?