PDA

View Full Version : How to set Local image to Ext.Img



22 Apr 2013, 8:09 AM
Hi,


I have a form panel.
I have an image element (Ext.Img).
I want to show a local image to image element.
I am selecting image from local folder by using File Uploader control.


On change action of File Uploader, I am doing like this


var win = filefield.up('window');
win.down('#image').setSrc(value);


But its not showing current image to image element.


Can someone help me, how to do it?


Thanks in advance.

slemmon
23 Apr 2013, 9:37 PM
What value are you getting from your filefield? Something like "/image.png"? (*what it returns may be different on different browsers.)

23 Apr 2013, 11:02 PM
Thanks for reply.

yes, I am getting different value in different browsers.

I have an image in my desktop.
In IE9 I am getting like "c:\Users\prakumar\Desktop\Hi.png"
In google crome like "c:\fakepath\Hi.png"

slemmon
24 Apr 2013, 9:06 AM
You would need to normalize the response and set the src with the relative path to the image. That or upload the image selected to a server and pass pack the location of the image for your setSrc().