How to show image when we choose the image path using Fileupload using javascript

Hello Mate,

I have a file upload control and i have a image control. if i choose the image path by clicking "Browse" button from the file upload , i have to show that image in the image control and this should be done by javascript, i have to validate for only image files while setting the image url to the image control

currently my code is

 

function setimage(obj)

{

var image=document.getElementById ('Image1');

 

document.getElementById(
'Image1').src= obj.value;

}

<asp:FileUpload Width="200px" onchange="setimage(this);" ID="FileUpload1" runat="server" />

 

but the above code is not working and it is not showing the selected image in the image control!!!

 

Could u please help me on this issue?


Much Obliged & Thanks a Lot,
Myself
0
Sidewinder2
1/17/2009 4:14:03 AM
asp.net.client-side 24353 articles. 2 followers. Follow

4 Replies
2942 Views

Similar Articles

[PageSpeed] 23

I think you cannot do that anymore as the current browsers are more secured! 

just go through this forum link which is related to php but discussing the same issue

http://forums.invisionpower.com/lofiversion/index.php/t226158.html

 

0
Dil
1/17/2009 6:14:23 AM

hi...

use this javascript

you can add more formats or restrict 

 

<html>
<head>
<script type="text/javascript">
function validate(oForm){
if (!/(\.(gif|jpg|jpeg|bmp|png))$/i.test(oForm.file1.value)){
alert("Please attach an image.");
oForm.file1.focus();
return false;
}
return true;
}
</script>
</head>
<body>
<form name="uploadForm" action="upload.php" method="post" enctype="multipart/form-data" onsubmit="return validate(this)" />
<input type="file" name="file1" />
<input type="submit" value="Save" />
</form>
</body>
</html>
  All The Best

Bhaarat

Remember to click "Mark as Answer" on the post that helps U

My Blog
-1
Bhaarat
1/17/2009 6:22:55 AM

here's a link

http://javascript.internet.com/forms/image-upload-preview.html


MAKMark as Answer if this reply helps you
MVP ASP/ASP.Net
MVP ASP/ASP.Net
ASP.Net Hosting : Host DepotMy Site : ASPSnippets
-1
mudassarkhan
1/17/2009 6:46:31 AM

mudassarkhan:

Sorry, but i think that Dil is correct. That script won't work any longer as the image would have to be uploaded to the server before you could display it. Try the script and you will see.

Also see here for an answer to the same question: http://forums.asp.net/t/1371116.aspx

NC...

 

0
NC01
1/18/2009 4:03:09 PM
Reply:

Similar Artilces:

How to link image on the client side not using image control
Hello: I need to link my image on the client side code, but not use image control. Is anyway like ASP to use: img src="../image/photo.gif" ?  Thanks    You meant  without adding image control you wanted to add an image and give the link for that? please give more details... Don't forget to click (Mark as Answer) on the post that helped to solve your problem. Yes. In ASP, you specify the image path: img src="../image/photo.gif". I put image in the folder image. How to specify this path and find image without using image contro...

How to use client-side script(javascript) in DNA using .Net Remoting
Hi all,     It was known that SAO and Singleton object about .Net Remoting. When I Create an object in server side and hosting in IIS's virtual directory,I want to use javascript asynchronous invoking the remote object by HTTP channel, 80 port and SOAP formatter just like XMLHTTP invoking web service. My code as following, <script> objXmlDoc = new ActiveXObject("Msxml2.DOMDocument"); objHttp = new ActiveXObject("Msxml2.XMLHTTP"); strEnvelope = ?? objHttp.onreadystatechange = function() { ...... }   szUrl = "http://ServerNa...

Loaing Image to an Image COntrol using client side java script
SIr How can I Load an Image to an Image Control using JavaScript Expecting reply C T Ranjith Hi ctranjith, Try the following snipplet and then call it wherever you need it: function LoagImage() { document.getElementById('imgControl1').src = document.getElementById('btnExplore').value; } Hope it helps.MIGUELÓN.-----------------------------------------Rezad a vuestros dioses, amad a vuestras mujeres y luchad por vuestra patria! ----------------------------------------...

3.0.4 Images Path
Hi, I have tryed clean install several times, just editet the connectionstring. But the same problem each time. Since no one else seams to have this problem I guess it has to do with my machine setup, but I can't figure it out. I run XP Pro, SQL 2000, .NET 1.1 When I 'View Source' on my page the image paths are not correct, it looks like this: 1. <img id="IconBar.ascx_imgAddTabIcon" src="Admin/ControlPanel/admin/ControlPanel/images/iconbar_addtab.gif" alt="Add New Page" border="0" /> 2. <img id="dnn_ctr3_Links_lstL...

3.0.4 Images Path
Hi, I have tryed clean install several times, just editet the connectionstring. But the same problem each time. Since no one else seams to have this problem I guess it has to do with my machine setup, but I can't figure it out. I run XP Pro, SQL 2000, .NET 1.1 When I 'View Source' on my page the image paths are not correct, it looks like this: 1. <img id="IconBar.ascx_imgAddTabIcon" src="Admin/ControlPanel/admin/ControlPanel/images/iconbar_addtab.gif" alt="Add New Page" border="0" /> 2. <img id="dnn_ctr3_Links_lstLinks__...

Storing images in SQL database vs storing images in seperate folder and using URL image path
Hi allCan you store images in a sql database and if so, does it store the images as an image file or does it store it in a binary format reducing the size of the image. If it can be stored in an sql database as a image or a binary format what are the advantages/disadvantages or is it better to store the url in the database and then bind the image holder to the url link in the database. Hi, These two ways are both ok. My suggestion is to store images into sql database if there are no much more images, otherwise, it's better store them into file system because you can store them no mat...

use javascript show image
Hi,everyone.I have a question.I am testing ajax now,I can write out image from web from in asp.net by use Response.Write() function and can get it from another page by javascript.I question is how show the image in another page by javascript?...

show image using javascript
Hi: I have created a javascript function, I can see all the values pass in, but somehow the big image doesn't show anything (the big image become white with "X"). function showBigImage(ImgBigId, ImgBtnURL) //trying to assign the ImgBtnURL to the Big image.{    var url;    url= ImgBtnURL.replace("~","..");  // the original ImgBtnURL is: "~/Images/myStory/abc.jpg", after this replace function: "../Images/myStory/abc.jpg"    document.getElementById(ImgBigId).src = url;    re...

Display image on page using full path of image
I am attempting to display an image in my Repeater control.  At run-time, I have only the full path of the image. (eg: c:\somedir\somedir\imagename.gif) The images are not located in the directory that the web application is running in. Is it possible to display the image?-Craig U-Sports.net - Taking Fantasy Football to School Yes you can. i.e.  "Repeater1" runat="server" DataSourceID="SqlDataSource1"> "Image" runat="server" ImageUrl="C:/myImage.gif" /> <%# Eval("fldTitle") %> ...

slide show of images using javascript
Hai I am using javascript to make a slide show of around 20 images. i am displaying 20 thumbnails first and its showing the big images with time intervel say 3 sec. the problem is i want to start the slide show only after all bigimages loaded to the memory. currently in each loop i am assigning src attribute of the image holder like src=dir/imagename.jpg I want to store images in one array variable and then starts the loop please help thanks in advanceThe real voyage of discovery consists not in making new landscapes, but in having new eyes use the readystate property of eac...

Cannot show image if I use absolute path
I have thousands of pictures stored in a directory with no relation to the asp application. I want to show these pictures in the asp application but seems like asp:Image control accepts only the relative paths. How can I show the pictures using the absolute paths? For test purposes I tried the following line which works:Image1.ImageUrl = "~/Images/9944483079.jpg"; but the one below does not although it resolves the same path: Image1.ImageUrl = "file///C:/Users/MyName/Documents/Visual Studio 2005/Projects/ProjectFolderName/ProjectName/Images/9944483079.jpg";   &n...

Adding images in crystal reports using URL path of the image
Hi... How to add images, whose URL path is stored in database..something like (http://<serverIP>/pictures/wqwq.jpg) to crystal report... Please help   You can try visiting the following URLs: http://aspalliance.com/1097_Importing_Dynamic_Images_to_the_Crystal_Report_without_Database_Overhead_using_Visual_Studio_2005 http://www.andybeaulieu.com/Home/tabid/67/EntryID/21/Default.aspx http://dotnetbd.wordpress.com/2008/06/20/display-dynamic-image-in-crystal-report-net/  I hope it helps.  Microsoft ASP.NET Enthusiast  hello ankit_jedi try this wayi ...

help image layout text using System.Drawing.Imaging; using System.Drawing;
using System.Drawing; using System.Drawing.Imaging;public partial class _Default : System.Web.UI.Page {protected void Page_Load(object sender, EventArgs e) {Image img1 = Image.FromFile(Server.MapPath("1.bmp"), true); Image img2 = Image.FromFile(Server.MapPath("2.bmp"), true);Bitmap img = new Bitmap(300, 300, PixelFormat.Format24bppRgb);Graphics g = Graphics.FromImage(img); g.DrawImageUnscaled(img1, 0, 0, img1.Width, img1.Height); g.DrawImage(img2, 100, 100, 50, 50);Font font = new Font("Arial", 20); SolidBrush brush = new SolidBrush(Color.Black);st...

How to show dynamic images using the right path?
Hey there, I got a masterpage in my root folder named MasterPage.master. My images for that MasterPage are located here: ~/images/Layout/*.jpg Now I created a subfolder in my Project called "ControlPanel". There I got several aspx sites which are using my MasterPage. I noticed that I have to include runat="server" when using the <img src=".."> tag to be able to use "~/" (So the MasterPage doesn't use "~/ControlPanel/images/*" because the images are located in "~/images/*". However, I got some dynamic images in my codebehind file(In the codebehind of one of those aspx in /Con...

Web resources about - How to show image when we choose the image path using Fileupload using javascript - asp.net.client-side

Bradstick (@bradstick_lsb) on Twitter
Sign in Sign up To bring you Twitter, we and our partners use cookies on our and other websites. Cookies help personalize Twitter content, tailor ...

Ho Chi Minh Thought - Wikipedia, the free encyclopedia
Ho Chi Minh Thought is an ideology that adapts Marxism–Leninism to the specific social, political, and economic conditions of the Vietnamese ...

Plop - Contact
Home What is Plop? Newsletter / RSS Boot Managers (2) Plop Linux Android Apps VHD Loader HFS+ Rescue Xorg Touchscreen pimgrestore Flybook Linux ...

Summer resort recommendation special
Summer resort recommendation special ,China Forum

Implementing an Image Gallery using ASP.NET MVC
访问文章了解更多信息。

Sitemap
Login Login To Subscribe This Plan Remember me Log in Forgot username? Forgot password? Registration Register Bang2Joom Pricing Templates Extensions ...

Content Management » Basex Blog »
Ten years ago, Basex laid the groundwork for the Collaborative Business Environment (CBE), a conceptual framework for a workspace for the knowledge ...

dotnetmackenzie
For the website, I've kept the default styles when you create a new ASP.NET Web Application, removing the two content pages that come by default ...

Latest Updates
Latest Updates - Free source code and tutorials for Software developers and Architects.; Updated: 15 Feb 2013

Apache Struts security update fixes critical vulnerabilities
The Apache Software Foundation has released Struts 2.3.15.1, a security update for its popular Java Web application development framework that ...

Resources last updated: 1/17/2016 5:44:48 PM