views:

31

answers:

0

Hi, 1. I am uploading an image by using iframe.

  1. From that iframe i call a callback function like imageuploaded("filename.jpg") which gets called after the image has properly uploaded. So after the php script executes i dump this as output ... die("<script>window.parent.window.imageuploaded('filename.jpg')</script>").

  2. This works perfectly.

  3. I wanted to show a resized image of the uploaded image after the function imageuploaded is called.

  4. So, i have an image tag with id='res' which will contain the resized image of the uploaded image.

  5. since i know the file name i call the resize function like this... document.getElementById('res').src = 'http://localhost/admincontrol/product?fn=filename.jpg&amp;uniq='+Math.random()

  6. consider the file name is url safe.

So here what should happen is that script dumps a dynamic images and the img tag will show that resized image.

This dosent work.

here is the javascript code the showresize function is still i am testing... as you can see...

function imageuploaded(msg)
{
    try {   
        var os = eval( "(" + msg + ")" )
    }catch(e) { alert(e); return; }

    if(os.status)showResize(os)
    else alert(os.err)
}

function showResize(os)
{
    $('#tori').css({'left': $(document).width()/2 - 700, 'display':'block'})
//  document.getElementById('toresize').src = baseurl+'products/thumbnailNew/'+os.filename+'/120/130/'+Math.random()
    document.getElementById('toresize').src = mainurl + 'static/productimages/' + os.filename

    window.setTimeout(function () {
        document.getElementById('toresize').src = baseurl+'products/thumbnailNew/'+os.filename+'/120/130/'+Math.random()+'/'
    },2000)
}

from the php code i create a json string and i am writing it to the function like the following... and the php part is working fine.

$err['status'] = 1;
$err['filename'] = $upres['file_name'];             
$err = addslashes(json_encode($err));
die("<script>window.parent.window.imageuploaded(\"$err\")</script>");       

When i checked with firebug in firefox it is showing the thumbnail but only after i hovered on its link (hope people know that firebug will show all the requests and the respective links and when hovered it will show a small image and with that we can see whether the image has been properly referred or not).

the html

<div id="tori" style=" position:absolute; display:none; left:0px; top:50px; width:700px; height:400px; background-color:white; border:10px solid #cecece;">
<div style=" display:block;width:500px; height:400px; overflow:auto;">
<img id="res" src="" style="border:5px solid red;" />
</div>
</div>

if i give a direct file name path it works properly but this is not displaying.

I did not show the php scrpt here because the same url when you copy and paste in the browser the thumbnail appears perfectly. but when dynamically displaying using javascript it is now showing on the screen.

as i have said if it is a direct image i am dynamically linking then it is showing... (i have used this i other projects) but dynamically created images is not loading.

What would be the discrepancy?