0

首先你好:)。

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

提及

我正在使用 Zend 框架。

我不明白为什么代码看起来那么糟糕。如果你想要一个干净的版本,那就是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();

}

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

4

1 回答 1

0

由于在 Zend Framework 中代码放置在控制器类中,函数onFileUploaded不再是全局函数,而是类成员。回调应该像这样添加:

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

请参阅http://php.net/manual/en/language.pseudo-types.php#example-86(死链接)关于 PHP 回调的文章。

于 2011-07-14T03:33:06.110 回答