0

这可能是一个新手问题,这是我的情况:

我有一个上传图片的上传表格。在我的editAction我做:

if ($request->isPost()) {
            if (isset($_POST['upload_picture']) && $formImageUpload->isValid($_POST)) {
                //here i will add the picture name to my database and save the file to the disk.
            }
}

$picVal = $this->getmainPic(); // here i do a simple fetch all and get the picture that was just uploaded

$this->view->imagepath = $picVal;

发生的情况是新上传的图片没有显示。我检查了数据库和鸡巴,文件在那里。

我认为问题可能是请求的顺序或类似的东西。

有任何想法吗?

编辑:另一件事是,为了使新图像出现,我必须执行 SHIFT+F5 而不仅仅是按下浏览器刷新按钮

编辑2:更多代码

我首先调用上传到磁盘函数然后如果返回成功将文件添加到数据库

$x = $this->uploadToDiskMulty($talentFolderPath, $filename)

if($x == 'success'){
    $model->create($data);
}

上传功能

public function uploadToDiskMulty($talentFolderPath, $filename)
{
    // create the transfer adapter
    // note that setDestiation is deprecated, instead use the Rename filter
    $adapter = new Zend_File_Transfer_Adapter_Http();
    $adapter->addFilter('Rename', array(
            'target'    => $filename,
            'overwrite' => true
    ));

    // try to receive one file
    if ($adapter->receive($talentFolderPath)) {
        $message = "success";
    } else {
        $message = "fail";
    }

    return $message;
 }
4

1 回答 1

1

如果图片仅在您执行 SHIFT+F5 时出现,则表示这是缓存问题。当您上传图片时,您的浏览器不会获取图片。你使用相同的文件名吗?

于 2012-05-07T23:22:47.920 回答