[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Send file upload to site on godaddy server

Posted on 2007-10-09
3
Medium Priority
?
2,000 Views
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);
                try
                {
                    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?
0
Comment
Question by:cbrick04
  • 2
3 Comments
 
LVL 27

Accepted Solution

by:
Sammy Ageil earned 2000 total points
ID: 20046767
use the PhysicalApplicationPath
example
 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
0
 

Author Comment

by:cbrick04
ID: 20046813
That is exactly what I needed, works perfect, thank you.
0
 
LVL 27

Expert Comment

by:Sammy Ageil
ID: 20046843
You are welcome, Glad I was of help
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Although a lot of people devote their energy toward marketing for specific industries, there are some basic principles that can be applied to any sector imaginable. We’ll look at four steps to take and examine how those steps were put into action fo…
Q&A with Course Creator, Mark Lassoff, on the importance of HTML5 in the career of a modern-day developer.
Viewers will get an overview of the benefits and risks of using Bitcoin to accept payments. What Bitcoin is: Legality: Risks: Benefits: Which businesses are best suited?: Other things you should know: How to get started:
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
Suggested Courses
Course of the Month17 days, 21 hours left to enroll

831 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