Social Icons

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.....

9 comments:

  1. Great post! I am actually getting ready to across this information, It’s very helpful for this blog.Also great with all of the valuable information you have Keep up the good work you are doing well.
    Digital Marketing Training in Chennai

    Digital Marketing Training in Bangalore

    digital marketing training in tambaram

    digital marketing training in annanagar

    ReplyDelete
  2. 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
  3. 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
  4. 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
  5. Howdy, would you mind letting me know which web host you’re utilizing? I’ve loaded your blog in 3 completely different web browsers, and I must say this blog loads a lot quicker than most. Can you suggest a good internet hosting provider at a reasonable price?


    Best AWS Training Institute in BTM Layout Bangalore ,AWS Coursesin BTM


    Best AWS Training in Marathahalli | AWS Training in Marathahalli

    Amazon Web Services Training in Jaya Nagar | Best AWS Training in Jaya Nagar


    AWS Training in BTM Layout |Best AWS Training in BTM Layout

    AWS Training in Marathahalli | Best AWS Training in Marathahalli

    ReplyDelete

 

Sample text

Sample Text