In this web programming tutorial we will learn that how we can upload an image or file directly on FTP by using asp.net file uploader control in asp.net using c# see the below code it will help us by doing so..
just copy and paste.
public void ftpfile(string ftpfilepath) { string ftphost = "Domain"; //here correct hostname or IP of the ftp server to be given string ftpfullpath = "ftp://" + ftphost + ftpfilepath; FtpWebRequest ftp = (FtpWebRequest)FtpWebRequest.Create(ftpfullpath); ftp.Credentials = new NetworkCredential("Domain", "Password"); //userid and password for the ftp server to given ftp.KeepAlive = true; ftp.UseBinary = true; ftp.Method = WebRequestMethods.Ftp.UploadFile; // Resize Image is function to resize the image System.Drawing.Image img1 = ResizeImage(FileUpload1.PostedFile.InputStream, 84, 118); // Convert the image into bytes Array; byte[] buffer = ImageToByte(img1); // Send the image file in form of bytes Stream ftpstream = ftp.GetRequestStream(); ftpstream.Write(buffer, 0, buffer.Length); ftpstream.Close(); }