我在用php zend框架上传多个文件时遇到问题
我有一个包含许多input[type="file"]标记的表单,每个标记都有其唯一的名称和id属性。
当接收到这些数据时,所有文件都聚集在一个数组文件中,我现在可以很容易地接收和存储它,但这里的问题是如何识别哪个文件来自哪个输入元素?知道这一点对我来说非常重要,因为每个特定的文件都将存储在数据库中的特定字段中。
这里是的一个例子
<input type "file" name = "main_photo"/>
<input type "file" name = "horizontal_plan"/>
$upload = new Zend_File_Transfer_Adapter_Http();
$files = $upload->getFileInfo();
foreach ($files as $file => $info)
{
if($upload->isValid($file))
{
//here how can i point to the main_photo file or the horizontal_plan file?
}
}
请帮忙,提前谢谢。
您可以看到它们如下:
PHP打印$_FILES
Array
(
[s1] => Array
(
[name] =>
[type] =>
[tmp_name] =>
[error] => 4
[size] => 0
)
[s2] => Array
(
[name] =>
[type] =>
[tmp_name] =>
[error] => 4
[size] => 0
)
)
<!--HTML FORM-->
<form method="post" enctype="multipart/form-data" action="t23.php">
<input type="file" name="s1">
<input type="file" name="s2">
<input type="submit">
</form>
正如您所看到的,html文件变量s1&s2变成一个数组,在PHP中有自己的一组数据。。。。您应该很容易确定每个数组对应于html中的namsake变量。:)
希望能有所帮助。