Reputation: 160
When using something like this in Zend:
$upload = new Zend_File_Transfer_Adapter_Http();
$upload->setDestination('/some/directory');
$upload->addValidator(x)
->addValidator(y);
$upload->receive();
Is the uploaded file uploaded first to a tmp directory, validated and then moved to 'some/directory' or is it directly saved into the setDestination directory? If the former, it seems to me that this does the same as "move_uploaded_file" after it's been uploaded to a tmp dir.
Does ZF offer some type of http stream handler to write file to a specific directory natively? i.e something similar to nodejs or django?
Upvotes: 1
Views: 433
Reputation: 296
Zend_File_Transfer_Adapter_Http
use move_uploaded_file
after verifying by validators that you assigned.
Look 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;
}
There are no special mechanisms, it is just a wrapper over the standard function
For direct uploading to your directory you may use something like
$input = fopen("php://input", "r");
$file = fopen("/my/directory/filename.eee", "w");
while ($data = fread($input, 1024)){
fwrite($file, $data);
}
but it seems in ZF is nothing like this
Upvotes: 2