在Zend中集成Aurigma Express

时间:2011-07-12 13:07:33

标签: php aurigma

首先你好:)。

花两天时间尝试集成 Aurigma Express 版本的PHP代码。

提及

我正在使用Zend Framework。

我不明白为什么代码看起来很糟糕。如果你想要一个干净的版本,那就是CodePad

我设法使思考成为“可见的”,但它没有做到`upload.php`应该做的事情。

注意:这是在控制器

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();

$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();

欢迎任何想法:)。谢谢你的时间。

1 个答案:

答案 0 :(得分:0)

因为在Zend Framework中,代码放在控制器类中,函数 onFileUploaded 不再是一个全局函数,而是一个类成员。并且应该添加回调,如:

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

请参阅有关PHP回调的http://php.net/manual/en/language.pseudo-types.php文章。