Send file upload to site on godaddy server

Posted on 2007-10-09
Last Modified: 2011-03-14
I have a website with an aspx page with c# code behind that I have had running on my own windows server. I have recently transfered the site to a godaddy shared server. I have a page where users can upload photos,  the code I have been using to do so is a follows:

This is in the button click event of the .cs file

// Send Upload
            string strFileName;
                UploadConfirmationTextBox.Text = "";
                strFileName = FileUpload.PostedFile.FileName;
                strFileName = strFileName.Substring(strFileName.LastIndexOf("\\") + 1);
                    FileUpload.PostedFile.SaveAs("D:\\WebsiteFolder\\Upload\\UploadedPics\\Origionals\\" + PictureNumberString);
                    UploadConfirmationTextBox.Text = "Uploaded successfully: " + strFileName;
                catch (Exception)
                    UploadConfirmationTextBox.Text = "Error Uploading " + strFileName;

It worked fine on my own server because the directory was D:.....
How do I change the directory for the shared hosting server?
Question by:cbrick04
    LVL 27

    Accepted Solution

    use the PhysicalApplicationPath
     Response.Write(HttpContext.Current.Request.PhysicalApplicationPath.ToString()); will get you your site PhysicalApplicationPath as in D:\\inetpub\wwwroot\APPLICATION_NAME
    your code should look like this

    FileUpload.PostedFile.SaveAs(HttpContext.Current.Request.PhysicalApplicationPath.ToString() +"\\Upload\\UploadedPics\\Origionals\\" + PictureNumberString);

    Good luck

    Author Comment

    That is exactly what I needed, works perfect, thank you.
    LVL 27

    Expert Comment

    You are welcome, Glad I was of help

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Suggested Solutions

    It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that undeā€¦
    Using SQL Scripts we can save all the SQL queries as files that we use very frequently on our database later point of time. This is one of the feature present under SQL Workshop in Oracle Application Express.
    This video teaches users how to migrate an existing Wordpress website to a new domain.
    The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

    737 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now