Example #1
0
        /// <summary>
        /// ////////////////////////////////////////////
        /// </summary>
        /// <param name="file"></param>
        /// <returns></returns>
        private string SubirImagen(HttpPostedFileBase file)
        {
            string nombre = "";

            if (file != null && file.ContentLength > 0)
            {
                try
                {
                    ArchivoBLL modelo = new ArchivoBLL();
                    nombre = DateTime.Now.ToString("yyyyMMddHHmmss") + file.FileName;
                    string path = Server.MapPath("~/Content/Imagenes/") + nombre;
                    modelo.SubirArchivo(path, file);
                    ViewBag.Message = modelo.confirmacion;
                }
                catch (Exception ex)
                {
                    ViewBag.Message = "ERROR:" + ex.Message.ToString();
                }
            }
            return(nombre);
        }
        private string SubirImagen(HttpPostedFile file)
        {
            string nombre = "";

            if (file != null && file.ContentLength > 0)
            {
                try
                {
                    ArchivoBLL modelo = new ArchivoBLL();
                    nombre = DateTime.Now.ToString("yyyyMMddHHmmss") + file.FileName;
                    string path = HttpContext.Current.Server.MapPath("~/Content/Imagenes/") + nombre;
                    modelo.SubirArchivo(path, file);
                    return(path);
                }
                catch (UnsupportedMediaTypeException)
                {
                    return("");
                }
            }
            return(nombre);
        }