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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T11:02:46+00:00 2026-05-25T11:02:46+00:00

I am saving an image file at server. The file is successfully saved at

  • 0

I am saving an image file at server. The file is successfully saved at the server but when I try to assign the URL of that file to the image control, the image is failed to load but when I assign that url directly in to HTML code, the file is loaded successfully. Please guide me Where I am making a mistake. Below are the code for my file upload and fetch URL.

Code For File Upload

private string ImageUpload()
{
    try
    {
        string FileName = UpldCompanyLogo.FileName;
        if (UpldCompanyLogo.HasFile)
        {
            string SaveFilePath = Server.MapPath("~\\Upload\\")+FileName;
            if (!Directory.Exists(Server.MapPath("~\\Upload\\")))
                Directory.CreateDirectory(Server.MapPath("~\\Upload\\"));

            if (File.Exists(SaveFilePath))
            {
                File.Delete(SaveFilePath);
            }
            if(File.Exists(ViewState["ImageURL"].ToString()))
            {
                File.Delete(ViewState["ImageURL"].ToString());
            }
            UpldCompanyLogo.PostedFile.SaveAs(SaveFilePath);
        }
        return FileName;

    }
    catch (Exception ex)
    {

        if (ex.HelpLink == null)
            ex.HelpLink = "Controls_Company103>>" + ex.Message;
        else
            ex.HelpLink = "Controls_Company103>>" + ex.HelpLink;
        lblMessage.Text = ex.HelpLink;
        lblMessage.CssClass = "ERROR";
        return null;
    }
}

This is the code to get the image URL

if (dtCompany != null)
            {
                if (dtCompany.Rows.Count > 0)
                {
                    txtCompanyName.Text = dtCompany.Rows[0]["CompanyName"].ToString();
                    txtAddress.Text = dtCompany.Rows[0]["Address"].ToString();
                    txtPhoneNo.Text = dtCompany.Rows[0]["PhoneNumber"].ToString();
                    txtFaxNo.Text = dtCompany.Rows[0]["FaxNumber"].ToString();
                     string path = Server.MapPath("~\\Upload\\");
                    imgLogo.ImageUrl = path + dtCompany.Rows[0]["CompanyLogo"].ToString();

                }
            }

If I copy and past the retrieved path in the browser, the image is found there at the server.

  • 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-25T11:02:47+00:00Added an answer on May 25, 2026 at 11:02 am

    You may try this:

    if (dtCompany != null)
    {
        if (dtCompany.Rows.Count > 0)
        {
            txtCompanyName.Text = dtCompany.Rows[0]["CompanyName"].ToString();
            txtAddress.Text = dtCompany.Rows[0]["Address"].ToString();
            txtPhoneNo.Text = dtCompany.Rows[0]["PhoneNumber"].ToString();
            txtFaxNo.Text = dtCompany.Rows[0]["FaxNumber"].ToString();
            imgLogo.ImageUrl = Page.ResolveUrl("~\\Upload\\") + dtCompany.Rows[0]["CompanyLogo"].ToString();
    
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm loading an image file from a web server, and then saving it to
I wonder when saving plot into image file in matlab, what is the difference
I have a dynamically created image that I am saving to a stream so
I'm having trouble with displaying image from db. I think that method for saving
Full edit: The scenario is that after uploading the file to the server via
I want to reduce image file size of an uploaded image before saving it
I am saving a file to a server and I'm saving the filename, user
Possible Duplicate: Saving image from PHP URL I have an image as a url
Saving data to Postscript in my app results in a Postscript file which I
Question In SQL Server 2005, I have a table with images (data type: image).

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.