Пример #1
0
    string SavePostedFile(UploadedFile uploadedFile)
    {
        string ret          = "";
        string base64String = "";

        if (!uploadedFile.IsValid)
        {
            return(string.Empty);
        }

        string fileName = Path.Combine(MapPath(UploadDirectory), ThumbnailFileName);

        using (Image original = Image.FromStream(uploadedFile.FileContent)) {
            base64String = PhotoUtils.ConvertImageToBase64(original);
            using (Image thumbnail = PhotoUtils.Inscribe(original, 100)) {
                PhotoUtils.SaveToJpeg(thumbnail, fileName);
            }
        }


        ret = string.Format("{0}|{1}", ThumbnailFileName, base64String);

        //return ThumbnailFileName;
        return(ret);
    }
        string SavePostedFile(UploadedFile uploadedFile)
        {
            string ret;
            string base64String;

            if (!uploadedFile.IsValid)
            {
                return(string.Empty);
            }

            var fileName = Path.Combine(MapPath(UploadDirectory), ThumbnailFileName);

            using (System.Drawing.Image original = System.Drawing.Image.FromStream(uploadedFile.FileContent))
            {
                base64String = PhotoUtils.ConvertImageToBase64(original);
                using (System.Drawing.Image thumbnail = PhotoUtils.Inscribe(original, 100))
                {
                    Session["UiImagenUsuario"] = "data:image/png;base64," + PhotoUtils.ConvertImageToBase64(thumbnail);
                    PhotoUtils.SaveToJpeg(thumbnail, fileName);
                }
            }
            ret = string.Format("{0}|{1}", ThumbnailFileName, base64String);

            return(ret);
        }
Пример #3
0
        string SavePostedFile(UploadedFile uploadedFile)
        {
            string ret;
            string base64String;

            if (!uploadedFile.IsValid)
            {
                return(string.Empty);
            }

            var fileName = Path.Combine(MapPath(UploadDirectory), ThumbnailFileName);

            /*using (System.Drawing.Image thumbnail = PhotoUtils.Inscribe(original, 100))
             * {
             *  PhotoUtils.SaveToJpeg(thumbnail, fileName);
             * }
             *
             * /*System.IO.FileInfo info = new System.IO.FileInfo(fileName);
             * string extension = System.IO.Path.GetExtension(uploadedFile.FileName).TrimStart('.');
             * string header = string.Format("data:image/{0};base64,", extension);
             *
             * var imgBase64 = Convert.ToBase64String(uploadedFile.FileBytes);
             * Session["UiLogoCentroDeDistribucion"] = "data:image/png;base64," + imgBase64;
             * return string.Format("{0}{1}", header, imgBase64);*/

            //var imgBase64  = "";
            using (System.Drawing.Image original = System.Drawing.Image.FromStream(uploadedFile.FileContent))
            {
                base64String = PhotoUtils.ConvertImageToBase64(original);
                using (System.Drawing.Image thumbnail = PhotoUtils.Inscribe(original, 100))
                {
                    Session["UiLogoCentroDeDistribucion"] = "data:image/png;base64," + PhotoUtils.ConvertImageToBase64(thumbnail);
                    //ret = string.Format("{0}|{1}", ThumbnailFileName, base64String);
                    PhotoUtils.SaveToJpeg(thumbnail, fileName);
                }
            }

            //Session["UiLogoCentroDeDistribucion"] = "data:image/png;base64," + base64String;
            ret = string.Format("{0}|{1}", ThumbnailFileName, base64String);

            return(ret);
        }