/    Sign up×
Community /Pin to ProfileBookmark

Image preview

Hi

I am very intrested to know how can i preview an image before the image gets uploaded to the server.In my application i can able to preview the uploaded image in the confimation page only.But how can i make a image preview without page gets refreshed.
I followed some code but it works only in IE and ask to run ActiveX controls

[code]
<HEAD>
<STYLE type=text/css>#newPreview {
FILTER: progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod=scale)
}
</STYLE>
<SCRIPT language=javascript type=text/javascript>
function PreviewImg(imgFile)
{
var newPreview = document.getElementById(“newPreview”);
newPreview.filters.item(“DXImageTransform.Microsoft.AlphaImageLoader”).src = imgFile.value;
newPreview.style.width = “80px”;
newPreview.style.height = “60px”;
}

</SCRIPT>

<TITLE> New Document </TITLE>
<META NAME=”Generator” CONTENT=”EditPlus”>
<META NAME=”Author” CONTENT=””>
<META NAME=”Keywords” CONTENT=””>
<META NAME=”Description” CONTENT=””>
</HEAD>

<BODY>
<input type=”file” id=”picField” onchange=”PreviewImg(this)”>
<div id=”newPreview”></div>

</BODY>
</HTML>
[/code]

Is there is any other common process to do this functions in all the browser.Is that possible with the help of YUI(Yahoo user Interface) or any other tools.

Thanks

to post a comment
JavaScript

4 Comments(s)

Copy linkTweet thisAlerts:
@FangApr 26.2009 — Cross browser image pre-view requires sending the image to the server first, then returning it to the document.
Copy linkTweet thisAlerts:
@sharemeauthorApr 27.2009 — Hi

Thank you for your reply.Is that possible to do this function by Ajax or YUI (Yahoo User Interface).
Copy linkTweet thisAlerts:
@bluestartechApr 27.2009 — try having a look at jquery and its plugins, it is quite good for UI stuff like this
Copy linkTweet thisAlerts:
@FangApr 27.2009 — Ajax can not upload images nor can JavaScript libraries or frameworks do it.

It would be possible in Fx if you could convince the user to lower their security restrictions.
×

Success!

Help @shareme spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.20,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...