Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8177361
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T23:29:20+00:00 2026-06-06T23:29:20+00:00

I want to display the image before uploading.I tried the following code but it

  • 0

I want to display the image before uploading.I tried the following code but it is working only in firefox.but i need to make it work in IE.Could any one suggest me the best solution for this.i am giving my code below could any one figure out where i went
I googled nearly one whole day.But couldnt find my solution
Here is my code

enter code here

function loadname(img, previewName) {
      var isIE = (navigator.appName == "Microsoft Internet Explorer");
      var path = img.value;
      var ext = path.substring(path.lastIndexOf('.') + 1).toLowerCase();
      if (ext == "gif" || ext == "jpeg" || ext == "jpg" || ext == "png") {
          if (isIE) {
              alert(path);
              $('#' + previewName).attr('src', path);
          } else {
              if (img.files[0]) {
                  var reader = new FileReader();
                  reader.onload = function (e) {
                      $('#' + previewName).attr('src', e.target.result);
                  }
                  reader.readAsDataURL(img.files[0]);
              } 
          }
      } 
  }  

My html is

 <body><form method="post" > 
<input type="file" class="file" onchange="loadname(this,'previewimg')" id="file" /><img src="about:blank" name="previewimg" id="previewimg" alt="" style="width:2in; height:2in"/> 


</form>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T23:29:22+00:00Added an answer on June 6, 2026 at 11:29 pm

    For security reasons IE9 does not support accessing of files on the client computer, that’s why you are not seeing any preview. You would need to upload the image onto your server and then display it.

    BIRD’S VIEW

    One way could be that on upload, show a progress bar while using ajax to save the file to a temporary folder on your server with the image name as a temporary ID and store the ID it in the database(so that you can delete it later) and then display it in the image control. If you need to delete the file later just delete it by using the ID or if you need it save it, move it to your images folder.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to display an image at the bottom of the screen and make
I am using asp.net with C# [3.5]. I want to display Image before my
I want to display the data extracted before in a customized list, but the
I want to display image using base64 encoding in IE using GWT If it
I want to display .jpg image in an Qt UI. I checked it online
I want to display an image using this php script on my server. $file
I want to display an image in my MKMapView instead of little rock pin
I want to display an image in a functional programming style. Basically, I operate
If I want to display an image in my webpage and its src is
I'm want to display different image version: first article: big banner second: small banner

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.