我正在使用laravel 5.6
。我正在尝试测试需要post
的{{1}}表单。
所以我写了
file
但是当我$file = new \Illuminate\Http\UploadedFile(base_path() . '/tests/samples/Cylinder.stl', 'Cylinder.stl');
$response = $this->post( route('attachments.store' ) , [
'file' => $file,
'attachable_id' => $this->threedviews->id,
'attachable_type' => 'App\ThreeDView',
]);
时,我得到了
dd( $this->app['session.store'] )
当我手动使用表格时,一切工作正常。
另外#bags: array:1 [
"default" => Illuminate\Support\MessageBag {#1198
#messages: array:1 [
"file" => array:1 [
0 => "The file failed to upload."
]
]
#format: ":message"
}
]
似乎很奇怪
$file
Illuminate\Http\UploadedFile {#43
-test: false
-originalName: "Cylinder.stl"
-mimeType: "application/octet-stream"
-error: 0
...
}
标志设置为false,应该是这样吗?