0

I am using Zend Framework in PHP and want to create validation on file uploads, the process these uploads for storage on the backend server. What information should I expect the FileTranser phonegap plugin to post, so that I know how to process this in the back end? Can Anyone help on this?

My code might look something like this.... but without documentation of the specifics, it's hard to write the back end code and the phonegap documentation does not give enough information.

$form = new Project_Forms_Post();
$request=$this->getRequest();
if ($this->_request->isPost() && $form->isValid($this->_request->getParams())) {
    $vals = $form->getValues();
    $post = new Project_Model_Post($vals);
    $post->save();
}

Zend Framework actually will process the file uploads as part of the form validation, so I just need to know basically, what name or names, as if coming from a form post with a input type=file, that the File plugin would attach to files.

Thanks

Damon Hogan
  • 552
  • 3
  • 14

1 Answers1

0

After spending quite a bit of time on this, I came up with a solution, this could probably be written a little better, such as putting a condition on $upload->receive() to do something on failure, but this works for now. I am using the Zend_File_Transfer class as trying to fool the form into accepting the file transfer through a file element just did not work I think because of the php file upload security in place etc.

$upload = new Zend_File_Transfer();
$upload->addValidator('MimeType', false, array('image/png', 'image/jpeg', 'image/gif', 'video/mpeg', 'video/mp4'));
//$upload->addValidator('Size', false, 200000);
$upload->setDestination(APPLICATION_PATH . "/../public/media/tmp");
$upload->receive();
$filename = $upload->getFileName();
$mimeType = $upload->getMimeType();

Damon Hogan
  • 552
  • 3
  • 14