Php 确定接收到哪些文件(多个上传文件zendframwork)
我在使用php zend framework上载多个文件时遇到问题 我有一个表单,其中包含许多输入[type=file]标记,每个标记都有其唯一的名称和id属性 当接收这些数据时,所有文件都聚集在一个数组文件中,我现在可以轻松地接收和存储它,但这里的问题是,我如何识别哪个文件来自哪个输入元素?知道这一点对我来说非常重要,因为每个特定的文件都将存储在数据库中的特定字段中 这里有一个例子Php 确定接收到哪些文件(多个上传文件zendframwork),php,zend-framework,Php,Zend Framework,我在使用php zend framework上载多个文件时遇到问题 我有一个表单,其中包含许多输入[type=file]标记,每个标记都有其唯一的名称和id属性 当接收这些数据时,所有文件都聚集在一个数组文件中,我现在可以轻松地接收和存储它,但这里的问题是,我如何识别哪个文件来自哪个输入元素?知道这一点对我来说非常重要,因为每个特定的文件都将存储在数据库中的特定字段中 这里有一个例子 <input type "file" name = "main_photo"/> <input
<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打印$\u文件
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变量
希望对您有所帮助。谢谢您,Pushpesh,但我尝试过,但当我打印文件[filename]时,它什么也不打印。请查看这是否对您有帮助-很遗憾,我一直在使用类似的代码进行上载,但我仍然无法解决问题,谢谢您的帮助。