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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T16:33:38+00:00 2026-05-25T16:33:38+00:00

I am doing a project : Front end – Visual Studio 2010 Technology :

  • 0

I am doing a project :

Front end - Visual Studio 2010

Technology : C#

Back end - Sql Server 2005

I am trying to upload a file using AsyncFileUpload Control and store it to “~/Image/” folder.

Script :

<asp:UpdatePanel ID="UpdatePanel1" runat="server">
    <ContentTemplate>
        <asp:ScriptManager ID="ScriptManager1" runat="server">
        </asp:ScriptManager>
        <asp:AsyncFileUpload ID="AsyncFileUpload1" runat="server" 
            onuploadedcomplete="AsyncFileUpload1_UploadedComplete"/>
    </ContentTemplate>

Code Behind :

protected void AsyncFileUpload1_UploadedComplete(object sender, AjaxControlToolkit.AsyncFileUploadEventArgs e)
{
    if (AsyncFileUpload1.HasFile)
    {
        AsyncFileUpload1.SaveAs("~/Image/" + AsyncFileUpload1.FileName);
        Label2.Text = "Recieved " + AsyncFileUpload1.FileName + " Content Type" + AsyncFileUpload1.PostedFile.ContentType;
    }
}

But everytime its showing runtime error called :

The SaveAs method is configured to require a rooted path, and the path '~\Image\Filename.jpg' is not rooted.

May I know the error and its solution.

Thanks in advance,

Nikhil

  • 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-25T16:33:38+00:00Added an answer on May 25, 2026 at 4:33 pm

    I figured it out:

    table width="100%" style="font: 8pt verdana">
                    <tr width="100%">
                    <td width="40%">
                        <asp:FileUpload ID="FileUpload1" runat="server" />
                        <asp:HiddenField ID="HiddenField1" runat="server" />
                    </td>
                    <td width="40%"><asp:Label ID="lblPicStatus" runat="server"></asp:Label></td>
                    <td>
                    <asp:Button ID="Button2" runat="server" Text="Upload" BackColor="White" 
                            BorderColor="#507CD1" BorderStyle="Solid" BorderWidth="1px" 
                            onclick="Button2_Click"/></td>
                    </tr>
    </table>
    

    Code Behind,

    protected void Button2_Click(object sender, EventArgs e)
    {
    
        try
        {
            con.Open();
            if (FileUpload1.HasFile)
            {
                String fileExt = Path.GetExtension(FileUpload1.FileName);
                if (fileExt == ".jpg" || fileExt == ".gif" || fileExt == ".bmp" || fileExt == ".jpeg" || fileExt == ".png")
                {
                    String path = "~/Image/" + FileUpload1.FileName;
                    cmd.CommandText = "update " + HttpContext.Current.User.Identity.Name + " set image = '" + path + "'";
                    cmd.Connection = con;
                    cmd.ExecuteNonQuery();
                    FileUpload1.SaveAs(Server.MapPath("~/Image/") + FileUpload1.FileName);
                    Response.Redirect(Request.RawUrl);
                }
                else
                {
                    lblPicStatus.Text = "File to be uploaded is not an image";
                }
                con.Close();
            }
        }
    
        catch (Exception a)
        {
            Response.Write(a.Message);
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a project with a RESTful Rails back-end and a Flex front-end, first
Background In my current project - a server product with no GUI front-end, I'm
I'm developing a project for doing Content Based Image Retrieval where front end will
I'm doing a project in a course at my university on distributed systems. I'm
I've been doing a project at work recently focused on an almost entirely client-driven
I'm doing a project in seam that requires restful URLs. I have a view
I'm on a project doing an iPhone application. We had a Cocoa consultant come
As I am currently doing this project in only C, I've up untill this
I'm doing an AutoLisp project which uses long associative structures to do heavy geometrical
I am very new to grails.I am doing one sample project for image uploading

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.