Saturday, March 24, 2012

Uploading Image or file on FTP programatically using Asp.net File Uploader

Dear friends following is the programmatic solution which can used to upload any image on FTP using FTP credentials....

 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();
}

Hope this will work for you.....

26 comments:

  1. This is quite educational arrange. It has famous breeding about what I rarity to vouch. Colossal proverb. This trumpet is a famous tone to nab to troths. Congratulations on a career well achieved. This arrange is synchronous s informative impolites festivity to pity. I appreciated what you ok extremely here 
    python training in OMR
    python training in Bangalore
    python training in rajajinagar
    Python training in btm
    Python training in usa

    ReplyDelete
  2. This looks absolutely perfect. All these tiny details are made with lot of background knowledge. I like it a lot. 
    java training in jayanagar | java training in electronic city

    java training in chennai | java training in USA

    ReplyDelete
  3. Good Post! Thank you so much for sharing this pretty post, it was so good to read and useful to improve my knowledge as updated one, keep blogging.
    angularjs Training in btm

    angularjs Training in electronic-city

    angularjs online Training

    angularjs Training in marathahalli

    angularjs interview questions and answers

    ReplyDelete
  4. Hi,
    Good job & thank you very much for the new information, i learned something new. Very well written. It was sooo good to read and usefull to improve knowledge. Who want to learn this information most helpful. One who wanted to learn this technology IT employees will always suggest you take python training in pune. Because Python course in pune is one of the best that one can do while choosing the course.

    ReplyDelete
  5. This comment has been removed by the author.

    ReplyDelete
  6. It's a very well and helpful post!!
    Thanks for sharing with us,
    We are again come on your website,
    Thanks and good day,
    If you need any logo then,
    Please visit our site,
    buylogo

    ReplyDelete
  7. Great post i must say and thanks for the information. Education is definitely a sticky subject. However, is still among the leading topics of our time. I appreciate your post and look forward to more.

    digital marketing courses mumbai

    ReplyDelete
  8. Sharing the same interest, Infycle feels so happy to share our detailed information about all these courses with you all! Do check them out
    oracle training in chennai & get to know everything you want to about software trainings.

    ReplyDelete
  9. Cool stuff you have and you keep overhaul every one of us, Great work.
    pmp certification bangalore

    ReplyDelete
  10. Infycle Technologies, the top software training institute and placement center in Chennai offers the Digital Marketing course in Chennai for freshers, students, and tech professionals at the best offers. In addition to the Oracle training, other in-demand courses such as DevOps, Data Science, Python, Selenium, Big Data, Java, Power BI, Oracle will also be trained with 100% practical classes. After the completion of training, the trainees will be sent for placement interviews in the top MNC's. Call 7504633633 to get more info and a free demo.

    ReplyDelete