我正在使用 laravel5.6并Dusk进行此特定测试。
我正在尝试在我的 dropzone 中声明文件上传。但是我的 Dropzone 是以我没有file输入元素的方式创建的。所以我不能使用该attach()方法。
所以我尝试了以下
$file = new \Symfony\Component\HttpFoundation\File\UploadedFile(base_path() . '/tests/samples/Cylinder.stl', 'Cylinder.stl');
$response = $this->actingAs( $this->user )
->from( 'my-url' )
->post( route('attachments.store' ) , [
'file' => $file
]);
Run Code Online (Sandbox Code Playgroud)
但是错误包包含这个错误
"errors" => Illuminate\Support\ViewErrorBag {#1194
#bags: array:1 [
"default" => Illuminate\Support\MessageBag {#1189
#messages: array:1 [
"file" => array:1 [
0 => "The file failed to upload."
]
]
#format: ":message"
}
]
}
Run Code Online (Sandbox Code Playgroud)
当然,当我手动执行时,这是有效的。