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 5931465
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T14:41:54+00:00 2026-05-22T14:41:54+00:00

I am uploading image using JQuery AjaxUpload and tried to update image control with

  • 0

I am uploading image using JQuery AjaxUpload and tried to update image control with that uploaded image but code is not working even not able to set ViewState. I want to know why it is happening. Below is code:

**Javascript:**<br>
<script type="text/javascript">    /*<![CDATA[*/<br>
        $(document).ready(function() {<br>
            /* Example 1 */<br>
            var button = $('#button1'), interval;<br>
            new AjaxUpload(button, {<br>
                action: 'fileupload.aspx',<br>
                name: 'myfile',<br>
                onSubmit: function(file, ext) {<br>
                    // change button text, when user selects file<br>
                    button.text('Uploading');<br>
                    // If you want to allow uploading only 1 file at time,<br>
                    // you can disable upload button<br>
                    // this.disable();<br>
                    // Uploding -> Uploading. -> Uploading...<br>
                    interval = window.setInterval(function() {<br>
                        var text = button.text();<br>
                        if (text.length < 13) {<br>
                            button.text(text + '.');<br>
                        } else {<br>
                            button.text('Uploading');<br>
                        }<br>
                    }, 200);<br>
                },<br>
                onComplete: function(file, response) {<br>
                    button.text('Upload');<br>
                    window.clearInterval(interval);<br>
                    // enable upload button<br>
                    this.enable();<br>
                    // add file to the list<br>
                    $('<li></li>').appendTo('#example1 .files').text(file);<br>
//                    document.getElementById('img').src = 'C:\\Documents and <br>Settings\\Kavita\\My Documents\\Visual Studio 2008\\WebSites\\WebSite2\\ajaxUpload\\' + file;<br>
//                    alert(document.getElementById('img').src);<br>
                }<br>
            });<br>
        });   /*]]>*/</script><br><br>

fileupload.aspx.cs Code

    HttpPostedFile hpfFile = Request.Files["myfile"];
    if (hpfFile != null)
    {
       hpfFile.SaveAs(Server.MapPath("~/ajaxUpload/" + hpfFile.FileName));
       img.Src = Server.MapPath("~/ajaxUpload/" + hpfFile.FileName);
    }<br>

Please let me know why “img.Src” not updating ?

  • 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-05-22T14:41:55+00:00Added an answer on May 22, 2026 at 2:41 pm

    The img.Src is updating on server side, but when you make an Ajax call, it is not sent back to the client side.

    If you want to display the image, it must be done in the onComplete jQuery function, as this code will be executed on client side, when the image has been completely uploaded.

    I also noted an error on the server method : you use Server.MapPath to set the image source, this is wrong because it will send you server’s path to the image (ie “C:\inetpub…”), you should only set the value as :

    img.Src = "~/ajaxUpload/" + hpfFile.FileName;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm working on a project that involves uploading an image to tumblr from Python.
I am using uploadify and my problem is that the files are not uploading.
I've implemented the following code for uploading photos inside a jQuery dialog (using an
I am using jQuery form plugin in my MVC project for image uploading. The
I am using Jquery form plugin. Popup is displayed with image uploading form. Image
How should I handle image uploading using PHP? How should I handle the chmod
I am using struts to build an image uploading module. However, I am encountering
I'm using UploadFy for uploading files on server but it doesn't work in firefox,
I am uploading an image to my Imagecollection model in using CarrierWave, and would
I'm uploading the image using aws-s3 gem, it uploads perfectly and give me the

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.