在Zend中使用类似的东西时:
$upload = new Zend_File_Transfer_Adapter_Http();
$upload->setDestination('/some/directory');
$upload->addValidator(x)
->addValidator(y);
$upload->receive();
上传的文件是先上传到tmp目录,验证然后移到'some / directory'还是直接保存到setDestination目录?如果是前者,在我看来,它在上传到tmp目录后与“move_uploaded_file”相同。
ZF是否提供某种类型的http流处理程序来将文件本地写入特定目录?类似于nodejs或django的东西?
答案 0 :(得分:2)
Zend_File_Transfer_Adapter_Http
在您分配的验证人验证后使用move_uploaded_file
。
看here:
public function receive($files = null)
{
if (!$this->isValid($files)) {
return false;
}
... some code ...
if (!move_uploaded_file($content['tmp_name'], $filename)) {
if ($content['options']['ignoreNoFile']) {
$this->_files[$file]['received'] = true;
$this->_files[$file]['filtered'] = true;
continue;
}
$this->_files[$file]['received'] = false;
return false;
}
没有特殊的机制,它只是标准函数的包装器
要直接上传到您的目录,您可以使用类似
的内容$input = fopen("php://input", "r");
$file = fopen("/my/directory/filename.eee", "w");
while ($data = fread($input, 1024)){
fwrite($file, $data);
}
但是在ZF中似乎不是这样的