/// <Summary> /// ajax uploads the user's avatar /// </summary> /// <param name = "uploadedFile"> </param> /// <returns> </returns> [HttpPost] public string AjaxUploadAvatar (HttpPostedFileBase uploadedFile) {string message = string. empty; var customer = _ workContext. currentCustomer; try {var customerAvatar = _ pictureService. getPictureById (customer. getAttribute <int> (SystemCustomerAttributeNames. avatarPictureId); if (up LoadedFile! = Null )&&(! String. isNullOrEmpty (uploadedFile. fileName) {int avatarMaxSize = _ customerSettings. avatarMaximumSizeBytes; if (uploadedFile. contentLength> avatarMaxSize) {message = string. format (_ localizationService. getResource ("Account. avatar. maximumUploadedFileSize "), avatarMaxSize); return message;} byte [] customerPictureBinary = uploadedFile. getPictureBits (); if (customerAvatar! = Null) customerAvatar = _ pictureService. updatePicture (customerAvatar. id, customerPictureBinary, uploadedFile. contentType, null, true); else customerAvatar = _ pictureService. insertPicture (customerPictureBinary, uploadedFile. contentType, null, true);} int customerAvatarId = 0; if (customerAvatar! = Null) customerAvatarId = customerAvatar. id; _ genericAttributeService. saveAttribute (customer, SystemCustomerAttributeNames. avatarPictureId, customerAvatarId); message = _ pictureService. getPictureUrl (customer. getAttribute <int> (SystemCustomerAttributeNames. avatarPictureId), _ mediaSettings. avatarPictureSize, false); return "1 |" + message;} catch (Exception exc) {message = exc. message; return message ;}}
View code: Avatar. cshtml
* Select an image on your computer to modify the current Avatar. The image is being uploaded. Please wait... @ T ("Account. Avatar. UploadRules ")
I will not talk about anything else. Welcome to join the group discussion with NopCommerce.