A strange name, yes, but the problem is simple; just aggressive. I have a form that I built without using Zend_Form, and it has two file uploads:
<input name="image" type="file" />
<input name="file" type="file" />
Here is a piece of code from my controller that handles the download. There's actually a bit more, but this is an important part:
$data['image'] = (isset($_FILES["image"]) && $_FILES["image"]["name"] ? $_FILES["image"]["name"] : NULL);
$data['file'] = (isset($_FILES["file"]) && $_FILES["file"]["name"] ? $_FILES["file"]["name"] : NULL);
$options = array('ignoreNoFile' => TRUE);
$upload = new Zend_File_Transfer();
$upload->setOptions($options)
->addFilter('Rename', array('target' => RESOURCES_IMG . $data['image'], 'overwrite' => TRUE), 'image')
->addFilter('Rename', array('target' => RESOURCES_FILES . $data['file'], 'overwrite' => TRUE), 'file')
->addValidator('ImageSize', false, array('minwidth' => 100,
'maxwidth' => 100,
'minheight' => 100,
'maxheight' => 100), 'image')
->addValidator('Extension', false, 'jpg', 'image');
if (!$upload->isValid())
{
echo '<h1>Oops</h1><p>Please correct the following errors: <hr /></p>';
foreach ($upload->getMessages() as $key => $val)
{
echo '<p><strong>' . $key . '</strong><br />' . $val . '</p>';
}
die;
}
else
{
$upload->receive();
}
This is pretty straight forward. $ Data stuff is just grabbing the file name if it's there, or setting the variable to NULL. I have my addFilter () and addValidator () segmented to affect only their respective files in this case "image" or "file" are the names of the form fields.
! , "" RESOURCES_FILES, . PDF , php8TJT13, phpXmOzQM ..
Qaru , Google , -, . !