Specifically the browsers that I mentioned that works with the code I am using is this: Opera, Mozilla, & Google Chrome. But on IE, and ME I get this error.
550 No Such File or Directory
While on the 3 browsers that I had mentioned this code works well, when I use the input type = "file", when I tried catching the error before without using the Web Exception, I got the error on line 37 which has this code
Stream requestStream = request.GetRequestStream();
HTML
<form id="form1" runat="server">
<div>
<input type="file" id="fuAttachment" runat="server"/>
<br />
<br />
<asp:Button ID="Button1" runat="server" Text="Button" onclick="Button1_Click" />
</div>
</form>
Code Behind
try
{
// Get the object used to communicate with the server.
FtpWebRequest request = (FtpWebRequest)WebRequest.Create("ftp://url/" + fuAttachment.PostedFile.FileName + "");
request.Method = WebRequestMethods.Ftp.UploadFile;
// This example assumes the FTP site uses anonymous logon.
request.Credentials = new NetworkCredential("username", "password");
// Copy the contents of the file to the request stream.
StreamReader sourceStream = new StreamReader(fuAttachment.PostedFile.InputStream);
byte[] fileContents = Encoding.UTF8.GetBytes(sourceStream.ReadToEnd());
sourceStream.Close();
request.ContentLength = fileContents.Length;
Stream requestStream = request.GetRequestStream();
requestStream.Write(fileContents, 0, fileContents.Length);
requestStream.Close();
FtpWebResponse response = (FtpWebResponse)request.GetResponse();
Response.Write("File Successfully Uploaded");
response.Close();
}
catch (WebException a)
{
String status = ((FtpWebResponse)a.Response).StatusDescription;
Response.Write(status);
}
What do I have to do to fix this problem? I don't think that I should be asking for the administrator to change the ftp settings, because this application works on the other browsers.