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

  • Home
  • SEARCH
  • 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 6091345
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T12:19:00+00:00 2026-05-23T12:19:00+00:00

I got this code that should help me save an image to the servers

  • 0

I got this code that should help me save an image to the servers file system:

      if (FileUpload1.HasFile)
    {

        string ImgName = FileUpload1.FileName;

        FileUpload1.SaveAs(Server.MapPath("~").ToString() + "\\" + ImgName);

        Stream imgStream = FileUpload1.PostedFile.InputStream;

        Bitmap bmThumb = new Bitmap(imgStream);

        System.Drawing.Image im = bmThumb.GetThumbnailImage(100, 100, null, IntPtr.Zero);

        im.Save(Server.MapPath("~").ToString() + "\\ThumbNail_" + ImgName);

    }

I dont know why they convert the image to a Thumbnail.. All I need is the image to be saved to the files system and retreived as a small image (for avatar)..

I save the filename as nvarchar(50) in my database.

My question is how do I retrieve the image from the filesystem. (I can get its path from the database, which is: Server.MapPath("~").ToString() + "\\ThumbNail_" + ImgName

Is all I need to do:

ImageControl1.imageUrl=Server.MapPath("~").ToString() + "\\ThumbNail_" + ImgName; 

Will the image appear in my ImageControl or not.

Can you criticize my code and add to it..cause it is the first time that i try to save and retrieve from the filesystem.

Will all that process work on my visual studio 2010 local 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-23T12:19:00+00:00Added an answer on May 23, 2026 at 12:19 pm

    Server.MapPath provides an absolute path to the image on the server. In order to serve the image to the client you need the relative path. So you may try using the ResolveUrl method:

    ImageControl1.ImageUrl = ResolveUrl("~/ThumbNail_" + ImgName); 
    

    or if I remember correctly the Image control already does this and you don’t need to explicitly call ResolveUrl, so the following might also work:

    ImageControl1.ImageUrl = "~/ThumbNail_" + ImgName; 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have got a piece of code, that should countdown some number (in this
Ok, I've got this code that I've been using to spit out news to
I've got this really simple piece of code that I thought was the correct
I got this javascript code from off the internet. It's a script that changes
I've got a problem with inheritance and generics. This is the code that illustrates
Got some code that is not mine and its producing this warning atm: iehtmlwin.cpp(264)
I got some legacy code that has this: <?PHP if(isset($_GET['pagina'])==homepage) { ?> HtmlCode1 <?php
I've got some code that looks like this: using (DBDataContext dc = new DBDataContext(ConnectionString))
I've got HTML code that roughly looks like this: <li id=someid-11> <img src=... alt=alt
So I've got some Java code that uses Jakarta HttpClient like this: URI aURI

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.