I need to upload file via ftp to host. The /home2/travele2
path created on the root of host
I can upload file via FileZilla program to the host, but when I try to upload file via website, it gets me this error:
The remote server returned an error: (550) File unavailable (e.g., file not found, no access).
What is the problem?
// Get the object used to communicate with the server.
FtpWebRequest ftpWebRequest = (FtpWebRequest)WebRequest.Create("ftp://00.00.00.00/home2/travele2");
ftpWebRequest.Method = WebRequestMethods.Ftp.UploadFile;
// This example assumes the FTP site uses anonymous logon.
ftpWebRequest.Credentials = new NetworkCredential("aaaaaaa", "0000000");
// Copy the contents of the file to the request stream.
StreamReader sourceStream = new StreamReader(Server.MapPath("/Content/Site.pdf"));
byte[] fileContents = Encoding.UTF8.GetBytes(sourceStream.ReadToEnd());
sourceStream.Close();
ftpWebRequest.ContentLength = fileContents.Length;
Stream requestStream = ftpWebRequest.GetRequestStream();
requestStream.Write(fileContents, 0, fileContents.Length);
requestStream.Close();
FtpWebResponse response = (FtpWebResponse)ftpWebRequest.GetResponse();
Console.WriteLine("Upload File Complete, status {0}", response.StatusDescription);
response.Close();