Hi,
I changed it to this code, but still it did not work and has an error:
Could not find file 'C:\Program Files (x86)\Common Files\Microsoft Shared\DevServer\10.0\System.Web.HttpInputStream'.
my code here:
private bool UploadToFTP(string strFTPFilePath, string strLocalFilePath, string strUserName, string strPassword)
{
try
{
System.Net.FtpWebRequest reqObj = (FtpWebRequest) WebRequest.Create(strFTPFilePath);
reqObj.Method = WebRequestMethods.Ftp.UploadFile;
reqObj.Credentials = new NetworkCredential(strUserName, strPassword);
FileStream fStream = File.OpenRead(strLocalFilePath);
byte[] fileContents = new byte[fStream.Length];
fStream.Read(fileContents, 0, (int) fStream.Length);
reqObj.ContentLength = fileContents.Length;
Stream requestStream = reqObj.GetRequestStream();
requestStream.Write(fileContents, 0, fileContents.Length);
requestStream.Close();
FtpWebResponse response = (FtpWebResponse) reqObj.GetResponse();
response.Close();
}
catch (Exception Ex)
{
Label1.Text = Ex.ToString();
}
return true;
}
protected void Button1_Click(object sender, EventArgs e)
{
if (imgFileUpload.HasFile)
{
string FileName = imgFileUpload.PostedFile.FileName;
string filePath = "ftp://www.ariavid.com/Upload/";
filePath += FileName;
UploadToFTP(filePath, imgFileUpload.PostedFile.InputStream.ToString(), "username", "password");
Image1.ImageUrl = "ftp://username:password@www.ariavid.com/Upload/" + FileName;
}
}
Best Regards,
shery