Click here to Skip to main content
15,892,643 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am facing the Error while Uploading the files on the Server, however it is working fine on my localhost.

My Server address where to upload the files are: http://www.tnp.somee.com/Uploads

I used the following Code:

XML
protected void Button1_Click(object sender, EventArgs e)
   {
       string filepath = "www.tnp.somee.com/Uploads";
       HttpFileCollection uploadedFiles = Request.Files;

       for (int i = 0; i < uploadedFiles.Count; i++)
       {
           HttpPostedFile userPostedFile = uploadedFiles[i];

           try
           {
               if (userPostedFile.ContentLength > 0)
               {
                   Label1.Text += "<u>File #" + (i + 1) +
                      "</u><br>";
                   Label1.Text += "File Content Type: " +
                      userPostedFile.ContentType + "<br>";
                   Label1.Text += "File Size: " +
                      userPostedFile.ContentLength + "kb<br>";
                   Label1.Text += "File Name: " +
                      userPostedFile.FileName + "<br>";

                   userPostedFile.SaveAs(filepath + "\\" +
                      System.IO.Path.GetFileName(userPostedFile.FileName));

                   Label1.Text += "Location where saved: " +
                      filepath + "\\" +
                      System.IO.Path.GetFileName(userPostedFile.FileName) +
                      "<p>";
               }
           }
           catch (Exception Ex)
           {
               Label1.Text += "Error: <br>" + Ex.Message;
           }
       }

   }



Error:
SQL
The SaveAs method is configured to require a rooted path, and the path 'www.tnp.somee.com/Uploads\Document.docx' is not rooted.



Please help me out as soon as Possible.
Posted
Updated 28-Jul-11 22:08pm
v5
Comments
Syed Salman Raza Zaidi 29-Jul-11 3:36am    
What error are you facing?
lovejeet0707 29-Jul-11 3:59am    
Error: The SaveAs method is configured to require a rooted path, and the path 'www.tnp.somee.com/Uploads\Document.docx' is not rooted.

 
Share this answer
 
Comments
lovejeet0707 29-Jul-11 5:00am    
No its Not Working Raja.
and i am not using ftp Server.
I Hope you can help more surely....
thatraja 31-Jul-11 11:26am    
Not clear man. Actually In my answer, the fix links are related to Non-ftp server too. so please check it & if still you have any doubt then reply me.
AFAIK, You cannot use the SaveAs method to write directly to an FTP server. Only local paths and UNC paths are supported.

To save it to FTP you have to use FtpWebRequest class.

Refer This[^] to get an idea.

hope it helps :)
 
Share this answer
 
Comments
lovejeet0707 29-Jul-11 4:56am    
I am not using ftp Server.
Uday P.Singh 29-Jul-11 6:56am    
then what does www.tnp.somee.com represents? I don't think its local
lovejeet0707 29-Jul-11 7:37am    
but i have not deployed my application using ftp.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900