I want to fake uploadedFile object in request object for testing purposes this way::
$image = new UploadedFile('public/testImage.jpg', 'testImage.jpg', filesize('public/testImage.jpg'), 'image/jpg', null, true);
$request = new Illuminate\Http\Request();
$request->replace([
'image' => $image,
]);
dd($request->hasFile('image'));
If I dump $request->toArray(), I see that it contains uploadedFile object:
array:1 [
"image" => Illuminate\Http\UploadedFile {#651
-test: false
-originalName: "testImage.jpg"
-mimeType: 9965
-size: "image/jpg"
-error: 0
path: "public"
filename: "testImage.jpg"
basename: "testImage.jpg"
pathname: "public/testImage.jpg"
extension: "jpg"
realPath: "/app/public/testImage.jpg"
aTime: 2017-02-01 15:45:03
mTime: 2017-01-31 15:35:05
cTime: 2017-01-31 15:35:05
inode: 15213368
size: 9965
perms: 0100775
owner: 1000
group: 1000
type: "file"
writable: true
readable: true
executable: true
file: true
dir: false
link: false
}
]
Unfortunately, $request->hasFile('image')
returns false.Tell me please, what am I doing wrong?
Aucun commentaire:
Enregistrer un commentaire