0

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;
 }
Patrioticcow
  • 26,422
  • 75
  • 217
  • 337

1 Answers1

1

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?

Reza S
  • 9,480
  • 3
  • 54
  • 84
  • Look at this: http://stackoverflow.com/questions/1077041/refresh-image-with-a-new-one-at-the-same-url – Reza S May 07 '12 at 23:29
  • just add a "?' to the end of the image name. This causes the browser to think it's new un-cached content and it'll fetch it again – Reza S May 07 '12 at 23:30