Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/spring-boot/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Zend framework phpthumb-zend框架_Zend Framework - Fatal编程技术网

Zend framework phpthumb-zend框架

Zend framework phpthumb-zend框架,zend-framework,Zend Framework,我可以上传图片并用phpthumb调整大小,但是我怎么也可以上传原始图片呢 if ($this->getRequest()->isPost()) { $formData = $this->getRequest()->getPost(); if ($form->isValid($formData)) { // upload the image if ($form->

我可以上传图片并用phpthumb调整大小,但是我怎么也可以上传原始图片呢

     if ($this->getRequest()->isPost()) {
        $formData = $this->getRequest()->getPost();
            if ($form->isValid($formData)) {

            // upload the image
            if ($form->station_image->isUploaded()) {
                $form->station_image->receive();
                $station_image = '/upload/images/radio/' . basename($form->station_image->getFileName());
                //upload thumb
                include_once '../library/PhpThumb/ThumbLib.inc.php'; 
                    $thumb = PhpThumbFactory::create($form->station_image->getFileName());                                    
                    $thumb->resize(50, 50)->save($form->station_image->getFileName()); 
                  //thumb ends



            }else{
                echo 'cannot upload'. exit;
            }
我的表格是这样的

$station_image->setLabel('Upload File: ')
                        ->setDestination(APPLICATION_PATH.'/../public/upload/images/radio')
                        ->addValidator('Extension', false, 'jpg,png,gif')
                        ->addValidator('Size', false, 902400)
                        ->addValidator('Count', false, 1)
                        ->setRequired(false);

请帮助我如何上传多个缩略图,或者如何上传原始文件?谢谢

您正在将原始图像传递给PHPThumb的构造函数:

$thumb = PhpThumbFactory::create($form->station_image->getFileName());
因此,
$form->station\u image->getFileName()
是您的原始文件。问题是您正在使用调整大小的文件名过度写入原始文件名,请尝试以下操作:

$thumb = PhpThumbFactory::create($form->station_image->getFileName());                                    
$thumb->resize(50, 50)->save('/path/where/you/want/resized/image/to/go.png');
--更新--

尝试一下:

if ($form->station_image->isUploaded()) {

    $form->station_image->receive();
    $station_image = '/upload/images/radio/' . basename($form->station_image->getFileName());
    //upload thumb
    include_once '../library/PhpThumb/ThumbLib.inc.php'; 
    $thumb = PhpThumbFactory::create($form->station_image->getFileName());

    // Notice this is using $station_image, which I assume is an accessible path
    // by your webserver                                    
    $thumb->resize(50, 50)->save($station_image); 
    //thumb ends

 }else{
--更新--

尝试更改此选项:

 $station_image = '/upload/images/radio/' . basename($form->station_image->getFileName());
为此:

 $station_image = '/upload/images/radio/thumb_' . basename($form->station_image->getFileName());

您正在将原始映像传递给PHPThumb的构造函数:

$thumb = PhpThumbFactory::create($form->station_image->getFileName());
因此,
$form->station\u image->getFileName()
是您的原始文件。问题是您正在使用调整大小的文件名过度写入原始文件名,请尝试以下操作:

$thumb = PhpThumbFactory::create($form->station_image->getFileName());                                    
$thumb->resize(50, 50)->save('/path/where/you/want/resized/image/to/go.png');
--更新--

尝试一下:

if ($form->station_image->isUploaded()) {

    $form->station_image->receive();
    $station_image = '/upload/images/radio/' . basename($form->station_image->getFileName());
    //upload thumb
    include_once '../library/PhpThumb/ThumbLib.inc.php'; 
    $thumb = PhpThumbFactory::create($form->station_image->getFileName());

    // Notice this is using $station_image, which I assume is an accessible path
    // by your webserver                                    
    $thumb->resize(50, 50)->save($station_image); 
    //thumb ends

 }else{
--更新--

尝试更改此选项:

 $station_image = '/upload/images/radio/' . basename($form->station_image->getFileName());
为此:

 $station_image = '/upload/images/radio/thumb_' . basename($form->station_image->getFileName());

谢谢,但如何设置相对路径来保存缩略图?请帮助它以前覆盖原始图像,现在它甚至不创建缩略图。我想知道在表单中设置目的地是否会导致问题。它说文件不可写:/upload/images/radio/thumb_grey.jpg,但是我检查了Folder中没有权限问题有两个路径,一个是文件系统中存在的完整路径,另一个是相对于docroot的路径。您需要确保apache用户可以访问完整路径(/path/to/your/image.png),并且apache用户具有对radio文件夹的写入权限;在表格中,如果我没有上传图片,我会得到空白页。我应该能够张贴没有图像。谢谢谢谢,但是我如何设置相对路径来保存缩略图呢?请帮助它以前覆盖原始图像,现在它甚至不创建缩略图。我想知道在表单中设置目的地是否会导致问题。它说文件不可写:/upload/images/radio/thumb_grey.jpg,但是我检查了Folder中没有权限问题有两个路径,一个是文件系统中存在的完整路径,另一个是相对于docroot的路径。您需要确保apache用户可以访问完整路径(/path/to/your/image.png),并且apache用户具有对radio文件夹的写入权限;在表格中,如果我没有上传图片,我会得到空白页。我应该能够张贴没有图像。谢谢