Ejemplo n.º 1
0
        public ActionResult UploadImage(long adaNo, HttpPostedFileBase file1, HttpPostedFileBase file2)
        {
            try
            {
                ProspectAvatar avatar1 = new ProspectAvatar();
                if (file1 != null && file1.IsImageFile())
                {
                    avatar1.img_streamdata = ConvertResizedImageToByteArray(file1);
                    avatar1.img_extension  = file1.GetImageFormat().ToString().ToLower();
                }

                ProspectAvatar avatar2 = new ProspectAvatar();
                if (file2 != null && file2.IsImageFile())
                {
                    avatar2.img_streamdata = ConvertResizedImageToByteArray(file2);
                    avatar2.img_extension  = file2.GetImageFormat().ToString().ToLower();
                }

                if (file1 == null && file2 == null)
                {
                    return(new JsonErrorResult(_resourceManager.GetString("ProfileImageMerging.UploadImage.NoFile"), HttpStatusCode.BadRequest));
                }

                _profileImageMergingService.UploadUsersImage(adaNo, avatar1, avatar2);

                return(new HttpStatusCodeResult(HttpStatusCode.OK));
            }
            catch (Exception ex)
            {
                _logger.Error("Error when uploading users' images: ", ex);
                return(new JsonErrorResult(ex.Message, HttpStatusCode.InternalServerError));
            }
        }
        public virtual ActionResult ImageUpload(HttpPostedFileBase file)
        {
            file.IsImageFile();
            var fileName = Guid.NewGuid() + Path.GetExtension(file.FileName);
            var filePath = Server.MapPath("~/App_Data/tmp/" + fileName);

            file.SaveAs(filePath);
            return(Json(new
            {
                url = Url.Action("Index", "Home", new { area = "File", name = fileName }),
                name = fileName
            }));
        }
Ejemplo n.º 3
0
        // GET: File/SlideShow
        public ActionResult Upload(HttpPostedFileBase file)
        {
            file.IsImageFile();

            var fileName = Guid.NewGuid() + Path.GetExtension(file.FileName);

            var filePath = Server.MapPath("~/Content/SlideShowImages/" + fileName);


            file.SaveAs(filePath);

            return(Json(fileName));
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Tries the get image file.
 /// </summary>
 /// <param name="file">The file.</param>
 /// <param name="onTypeFound">The on type found.</param>
 /// <param name="onContentFound">The on content found.</param>
 /// <returns></returns>
 public static bool TryGetImageFile(this HttpPostedFileBase file, Action <string> onTypeFound, Action <byte[]> onContentFound)
 {
     return(file.IsImageFile() && file.TryGetFileUpload(onTypeFound, onContentFound));
 }