我正在为wordpress开发一个插件,我希望能够从一个表单上传多张图片。现在,当我有一个包含两张图片的表单并提交它时,我的$_FILES数组看起来像这样:
Array (
[image] => Array (
[name] => Array (
[1] =>
[2] =>
)
[type] => Array (
[1] =>
[2] =>
)
[tmp_name] => Array (
[1] =>
[2] =>
)
[error] => Array (
[1] => 4
[2] => 4
)
[size] => Array (
[1] => 0
[2] => 0
)
)
)
现在的问题是,我想使用wordpress的上传处理程序wp_handle_upload。它需要$_FILES数组作为参数,但只能有一个文件。我猜它只能有两个数组深,而不是我的三个。所以我想知道是否有一种方法可以从$_FILES数组中一次提交一个文件。每个数组中的文件都有相同的键。
编辑:自从我了解到wp_handle_upload需要$_FILES数组作为参数后,就修改了帖子。
3条答案
按热度按时间e4eetjau1#
试试看:
lymgl2op2#
难道不能循环遍历文件数组,然后调用upload_handlers吗?
例如:
x9ybnkn63#
我试过这个,对我很有效
并使用此功能上传