Hi
I've been using the Zend Framework rather intensively to develop my website, and I'm now designing the upload interface. I need to allow the user to upload 1-5 images. I need to send these images to the database as a BLOB object. My current code is something like this:
$upload = new Zend_File_Transfer_Adapter_Http();
$upload->addValidator('Extension', true, 'jpg,png,gif');
$upload->addValidator('ImageSize', true, array(
'minwidth' => 4)); //i preform this check to make sure that it's a real
//image, since IsImage only checks MIME. Good Idea?
$upload->addValidator('IsImage', false);
$upload->addValidator('Size', true, array(
'min' => '5kB' ,
'max' => '1MB' ,
'bytestring' => false));
if (! $upload->receive()) {
$messages = $upload->getMessages();
echo implode("\n", $messages);
I have two questions.
First, what is a good, fast and secure way to confirm that the upload file is actually an image? MIME types and extentions can be easily faked. What I did adove seems foolish. Any other ideas?
Second, where do I proceed from here? I know Zend has the setDestination
method, but I'm moving it to a database, not to a file.
Thanks.