i figure it out. I'm using Zend Framework.
the issue is that the $_FILE
looses the size
and type
if you ask for it after the Api_Model_UploadHandler
initialization because the tmp
image gets removed.
so by asking for the image before seems to work ok.
no need to check if the file exists
public function imageUploadAction()
{
// in case some other crap goes wrong on the website, i want a clean json response
error_reporting(0);
$this->_helper->layout->disableLayout();
$this->_helper->viewRenderer->setNoRender(TRUE);
// get the request
$request = $this->getRequest();
// get other params if you sent any
$fileName = !empty($_FILES) ? $_FILES["files"]["name"][0] : '_';
if (file_exists('tmp/' . $fileName)) {
$upload = new Zend_File_Transfer_Adapter_Http();
if (is_null($files)) {
$files = $upload->getFileInfo();
}
// ... do a regular zend image upload
}
// initialize the upload
$uploadHandler = new Api_Model_UploadHandler();
$uploadHandler->initialize();
return json_encode(array());
}