怎麼是你應該使用「CakePhpRequest」上傳多個文件時的陣列?CakePHP的2.X上傳多個文件在同一時間
我使用了一些這樣的結果
CakeRequest Object
(
[params] => Array
(
[plugin] =>
[controller] => users
[action] => upload
[named] => Array
(
)
[pass] => Array
(
)
[form] => Array
(
[files] => Array
(
[name] => Array
(
[0] => php.exe
[1] => php.gif
[2] => php.ini
[3] => php.ini-development
[4] => php.ini-production
)
[type] => Array
(
[0] => application/x-msdownload
[1] => image/gif
[2] => application/octet-stream
[3] => application/octet-stream
[4] => application/octet-stream
)
[tmp_name] => Array
(
[0] => C:\xampp\tmp\php455E.tmp
[1] => C:\xampp\tmp\php456E.tmp
[2] => C:\xampp\tmp\php456F.tmp
[3] => C:\xampp\tmp\php4570.tmp
[4] => C:\xampp\tmp\php4571.tmp
)
[error] => Array
(
[0] => 0
[1] => 0
[2] => 0
[3] => 0
[4] => 0
)
[size] => Array
(
[0] => 73728
[1] => 2523
[2] => 78907
[3] => 72908
[4] => 72941
)
)
)
)
[...] other data
我一定要計算有多少文件已被上傳,然後遍歷所有?
那豈不是更容易,如果輸出是這樣嗎?
CakeRequest Object
(
[params] => Array
(
[plugin] =>
[controller] => users
[action] => upload
[named] => Array
(
)
[pass] => Array
(
)
[form] => Array
(
[files] => Array
(
[0] => Array(
[name] => php.exe
[type] => application/x-msdownload
[tmp_name] => C:\xampp\tmp\php455E.tmp
[error] => 0
[size] => 73728
)
[1] => Array(
[name] => php.gif
[type] => image/gif
[tmp_name] => C:\xampp\tmp\php456E.tmp
[error] => 0
[size] => 2523
)
[...] more data
)
)
)
[...] other data
這樣,我只需要使用的foreach($文件作爲$文件)
對不起,我英文不好
更多參考結算(這一職位)http://bakery.cakephp.org/articles/veganista/2012/01/31/html_5_multiple_file_upload_with_cake] ... –
謝謝你,這種方法解決了我的問題。 =) –
只要給我發現的任何人使用此解決方案的說明。 「。」將導致錯誤不顯示(也許在窗體幫助器中的錯誤)。所以我沒有包括「。」在字段名稱中手動將字段名稱放入選項數組「'name'=>'data [Model] [fieldname] []'中。 – lordg