Integrating Aurigma Express in Zend

130 Views Asked by At

First of all hello :).

Spend two days trying to integrate Aurigma Express version PHP code.

Mentions

I am using Zend Framework.

I don't get it why the code looks that bad .If you want a clean version here it is CodePad

I've managed to make the think to be `visible` but it fails to do what `upload.php` should do .

Note : This is in the Controller

function onFileUploaded($uploadedFile) { $absGalleryPath = realpath($this->_path) . DIRECTORY_SEPARATOR;
$originalFileName = $uploadedFile->getSourceName(); $files = $uploadedFile->getConvertedFiles(); $sourceFile = $files[0]; if ($sourceFile){ $sourceFile->moveTo($absGalleryPath . $originalFileName); } }

public function uploadImagesAction(){

$this->_session->message = $this->_session->messages['message_backend_product_image_notification_succesfully_added'];

require_once ROOT_PATH . "/Aurigma/ImageUploaderPHP/UploadHandler.class.php";
require_once ROOT_PATH . "/Aurigma/ImageUploaderPHP/UploadedFile.class.php";

$product_id = $this->_getParam('prod');
$product = Model_Product::getById($product_id);
$this->_path = "http://rstcenter.com/forum/images/products/".$product['id']."/";
$uploadHandler = new UploadHandler();

$uploadHandler->saveFiles(realpath($this->_path));

$uploadHandler->setFileUploadedCallback('onFileUploaded');

$uploadHandler->processRequest();

}

Any ideas are welcomed :). Thanks for your time.

1

There are 1 best solutions below

0
On

Since in Zend Framework the code placed inside controller class, function onFileUploaded is not a global function anymore, but a class member. And callback should be added like:

$uploadHandler->setFileUploadedCallback(array($this, 'onFileUploaded'));

See http://php.net/manual/en/language.pseudo-types.php#example-86(dead link) article about callbacks in PHP.