Patrioticcow
Patrioticcow

Reputation: 27048

php, data not updating after form post in zend?

this might be a bit of a novice question and here is my situation:

i have a upload form for uploading images. and in my editAction i do:

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;

what happens is that the newly uploaded picture doesn't show. I checked the database and the dick and the file is there.

im thinking the problem might be the order of the requests or something similar.

any ideas?

edit: another thing is that in order to make the new image come up i have to do a SHIFT+F5 and not only press the browser refresh button

edit2: more code

i first call the upload to disk function then if that returns success addthe file to the database

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

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

the upload function

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;
 }

Upvotes: 0

Views: 218

Answers (1)

Reza S
Reza S

Reputation: 9748

If the picture only appears when you do SHIFT+F5 that means it's a caching problem. Your browser doesn't fetch the image when you upload it. Do you use the same file name?

Upvotes: 1

Related Questions