Sunday, August 22, 2010

image upload...ajax process only works once

hi,

i am having a weird problem. on a site, a user can upload a picture.
when its uploaded the picture gets loaded in a div area as a preview.
now that works fine. but if i do this whole thing again, maybe cause i
want a different picture, the new picture is not loaded, although the
uploading process worked. i checked on my HDD.

this is what i do:

i have a form for the file uploading in my view:
<?php
echo $form->create('Link',
array('name'=>'uploadProfileImageForm','id'=>'uploadProfileImageForm','type'=>'file'));
echo $form->file('Link');
?>
<div class="submit">
<button onClick="functionCaller(this.form)" type="button">Hochladen</
button></div>
<?php
echo $form->end();
?>

now a JS function is called to acutally upload the pic, to show the
ajax loading icon, and to call the function, that acutally renders the
uploaded image in a specific div for a preview.

function functionCaller(form)
{
ajaxUpload(form,'processFlyer','flyer_css','<img src=\'../img/icons/
loader.gif\' width=\'16\' height=\'16\' border=\'0\' />','Fehler beim
Upload');
setTimeout("refreshflyer()", 500);
//refreshdiv();
}

calling a controller function to render the pic from this JS function

function refreshflyer(){

$('#flyer_preview').load('renderflyerpreview');
}

and that is the functin in my controller that gets the path to the
image and renders it in a div in my view

function renderflyerpreview()
{
$this->set('link_flyer_path_temp', ($this->Session-
>read('Link.flyer_path_temp')));
$this->render('render_flyer','ajax');
}


as i said it works fine the first time you do upload an image...the
second time...nope...the image gets uploaded, but not rendered!!??
is this some sort of caching problem?

BIG THX :)

Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.

You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate