这可能是一个新手问题,这是我的情况:
我有一个上传图片的上传表格。在我的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;
}