SHARE
TWEET

Untitled

a guest Jan 12th, 2017 75 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //File Reader
  2. function OnFileEditImageEntry(file) {
  3. var reader = new FileReader();
  4. reader.onloadend = function (evt) {
  5.     var ImageBase64 = evt.target.result;
  6.     return ImageBase64 ;
  7. };
  8. reader.readAsDataURL(file);
  9.  }
  10.  
  11.  //WEB API//
  12. public  IHttpActionResult UpdateUserDetails(userModel user)
  13.  {
  14.  
  15.   try
  16.     {
  17.        if (user.ProfileImageBase64 != "" && user.userID !=0)
  18.         {
  19.           var UserProfilePicDataUrl = "";
  20.            string ftpurl = "ftp://xxx.xxxxx.xxxx/";
  21.            var username = "xxx";
  22.            var password = "xxxxx";
  23.             string UploadDirectory = "xxxx/xx";
  24.              string FileName =ImageFileName;
  25.              String uploadUrl = String.Format("{0}{1}/{2}", ftpurl, UploadDirectory,FileName);
  26.                 FtpWebRequest req = (FtpWebRequest)FtpWebRequest.Create(uploadUrl);
  27.                 req.Proxy = null;
  28.                 req.Method = WebRequestMethods.Ftp.UploadFile;
  29.                 req.Credentials = new NetworkCredential(username, password);
  30.                 req.EnableSsl = false;
  31.                 req.UseBinary = true;
  32.                 req.UsePassive = true;
  33.                 byte[] data =Convert.FromBase64String(user.ImageBase64);
  34.                 req.ContentLength = data.Length;
  35.                 Stream stream = req.GetRequestStream();
  36.                 stream.Write(data, 0, data.Length);
  37.                 stream.Close();
  38.      }
  39.       }
  40.     }
RAW Paste Data
Top