我有一個問題讓上傳byoneupuploaderbundle獲取文件
如果我使用
$this->getRequest()->files[0]->getClientOriginalName();
(看到這個職位Get Uploaded File's Original Name)文件的原單名 的原始名稱我有這樣的錯誤:
FatalErrorException: Error: Cannot use object of type Symfony\Component\HttpFoundation\FileBag as array in /home/.../UploadListener.php line 17
,但我認爲是正確的,看到的var_dump:
$request = $event->getRequest();
var_dump($request->files);
給:
object(Symfony\Component\HttpFoundation\FileBag)#11 (1) {
["parameters":protected]=>
array(1) {
["file"]=>
array(1) {
[0]=>
object(Symfony\Component\HttpFoundation\File\UploadedFile)#12 (7) {
["test":"Symfony\Component\HttpFoundation\File\UploadedFile":private]=>
bool(false)
["originalName":"Symfony\Component\HttpFoundation\File\UploadedFile":private]=>
string(22) "silk_icons_preview.png"
["mimeType":"Symfony\Component\HttpFoundation\File\UploadedFile":private]=>
string(9) "image/png"
["size":"Symfony\Component\HttpFoundation\File\UploadedFile":private]=>
int(116463)
["error":"Symfony\Component\HttpFoundation\File\UploadedFile":private]=>
int(0)
["pathName":"SplFileInfo":private]=>
string(14) "/tmp/php3GUXwQ"
["fileName":"SplFileInfo":private]=>
string(9) "php3GUXwQ"
}
}
}
}
謝謝!
$請求 - >文件這是不是喜歡你的var_dump數組告知:Symfony的\組件\ HttpFoundation \ FileBag – MouradK