protected void MultipleFileUpload2_Click(object sender, FileCollectionEventArgs e)
    {
        HttpFileCollection oHttpFileCollection = e.PostedFiles;
        HttpPostedFile     oHttpPostedFile     = null;
        String             validFiles          = "gif, jpg, bmp, png";

        if (e.HasFiles)
        {
            oHttpPostedFile = oHttpFileCollection[0];
            if (oHttpPostedFile.ContentLength > 0)
            {
                if (validFiles.IndexOf(oHttpPostedFile.FileName.Substring(oHttpPostedFile.FileName.LastIndexOf(".") + 1)) > 0)
                {
                    oHttpPostedFile.SaveAs(Server.MapPath("Hinh Anh") + "\\" + System.IO.Path.GetFileName(oHttpPostedFile.FileName));
                    //LabLogo.InnerText = "./Hinh Anh/" + System.IO.Path.GetFileName(oHttpPostedFile.FileName);
                    //LabBanner.Text = Server.MapPath("./Hinh Anh/") + System.IO.Path.GetFileName(oHttpPostedFile.FileName);
                    //SetJavaScriptBanner(System.IO.Path.GetFileName(oHttpPostedFile.FileName));
                    XmlDocument Tai_lieu = new XmlDocument();
                    XmlElement  Cong_ty  = null;

                    Tai_lieu.Load(Server.MapPath("He Phuc Vu/CONG_TY.xml"));
                    Cong_ty = Tai_lieu.DocumentElement;

                    Cong_ty.SetAttribute("Banner", "./Hinh Anh/" + System.IO.Path.GetFileName(oHttpPostedFile.FileName));
                    Tai_lieu.Save(Server.MapPath("He Phuc Vu/CONG_TY.xml"));
                }
            }
        }
    }
Example #2
0
        protected void MultipleFileUpload1_Click(object sender, FileCollectionEventArgs e)
        {
            try
            {
                String dirDoc = obtenerDirDocs() + @"Procesando\";
                ldirDes.Text = dirDoc;
                DirectoryInfo directorioOrigen = new DirectoryInfo(dirDoc);
                bool          ban = false;

                if (!directorioOrigen.Exists)
                {
                    directorioOrigen.Create();
                }

                HttpFileCollection oHttpFileCollection = e.PostedFiles;
                HttpPostedFile     oHttpPostedFile     = null;
                if (e.HasFiles)
                {
                    for (int n = 0; n < e.Count; n++)
                    {
                        oHttpPostedFile = oHttpFileCollection[n];
                        if (oHttpPostedFile.ContentLength <= 0)
                        {
                            continue;
                        }
                        else
                        {
                            String   nom   = System.IO.Path.GetFileName(oHttpPostedFile.FileName);
                            String[] datos = nom.Split('.');
                            if (datos[1].Equals("xml") || datos[1].Equals("XML"))
                            {
                                ban = true;
                                oHttpPostedFile.SaveAs(dirDoc + System.IO.Path.GetFileName(oHttpPostedFile.FileName));
                                archivos.Add(dirDoc + System.IO.Path.GetFileName(oHttpPostedFile.FileName));
                                anade_linea_archivo(archivo_log, "MultipleFileUpload1_Click: " + System.IO.Path.GetFileName(oHttpPostedFile.FileName));
                            }
                        }
                    }
                    countArch.Text = archivos.Count.ToString();
                    if (archivos.Count > 0)
                    {
                        obtenerCFDI2();
                        tipoProcesar.Visible = false;
                        facturas.Visible     = true;
                        ClientScript.RegisterStartupScript(this.GetType(), "myScript", "<script>javascript: alert('Los archivos fueron cargados, ahora pueder continuar.');</script>");
                    }
                    else
                    {
                        ClientScript.RegisterStartupScript(this.GetType(), "myScript", "<script>javascript: alert('Solo se pueden subir archivos XML.');</script>");
                    }
                }
            }
            catch (Exception ex)
            {
                anade_linea_archivo(archivo_log, "MultipleFileUpload1_Click: " + ex.ToString());
            }
        }
    protected void MultipleFileUpload1_Click(object sender, FileCollectionEventArgs e)
    {
        HttpFileCollection oHttpFileCollection = e.PostedFiles;
        HttpPostedFile     oHttpPostedFile     = null;
        String             validFiles          = "gif, jpg, bmp, png";

        if (e.HasFiles)
        {
            oHttpPostedFile = oHttpFileCollection[0];
            if (oHttpPostedFile.ContentLength > 0)
            {
                if (validFiles.IndexOf(oHttpPostedFile.FileName.Substring(oHttpPostedFile.FileName.LastIndexOf(".") + 1)) > 0)
                {
                    oHttpPostedFile.SaveAs(Server.MapPath("Hinh Anh") + "\\" + System.IO.Path.GetFileName(oHttpPostedFile.FileName));
                }
            }
        }
    }
Example #4
0
    protected void MultipleFileUpload1_Click(object sender, FileCollectionEventArgs e)
    {
        HttpFileCollection oHttpFileCollection = e.PostedFiles;
        HttpPostedFile     oHttpPostedFile     = null;
        String             validFiles          = "gif, jpg, bmp, png, GIF, JPG, BMP, PNG";

        if (e.HasFiles)
        {
            oHttpPostedFile = oHttpFileCollection[0];
            if (oHttpPostedFile.ContentLength > 0)
            {
                if (validFiles.IndexOf(oHttpPostedFile.FileName.Substring(oHttpPostedFile.FileName.LastIndexOf(".") + 1)) > 0)
                {
                    String path = "Hinh Anh\\San Pham\\Thuc don" + "\\" + System.IO.Path.GetFileName(oHttpPostedFile.FileName);
                    oHttpPostedFile.SaveAs(Server.MapPath(path));
                    txtHinhAnh.Value = path;
                }
            }
        }
    }
Example #5
0
    protected void MultipleFileUpload1_Click(object sender, FileCollectionEventArgs e)
    {
        HttpFileCollection oHttpFileCollection = e.PostedFiles;
        HttpPostedFile     oHttpPostedFile     = null;

        if (e.HasFiles)
        {
            for (int n = 0; n < e.Count; n++)
            {
                oHttpPostedFile = oHttpFileCollection[n];
                if (oHttpPostedFile.ContentLength <= 0)
                {
                    continue;
                }
                else
                {
                    oHttpPostedFile.SaveAs(Server.MapPath("Files") + "\\" + System.IO.Path.GetFileName(oHttpPostedFile.FileName));
                }
            }
        }
    }
Example #6
0
        public ActionResult SaveAutoClaim()
        {
            var    file          = new FileCollectionEventArgs(this.Request);
            var    response      = new List <string>();
            int    uploadedFiles = 0;
            string Type          = "A";
            HttpFileCollectionBase oHttpFileCollection = file.PostedFiles;
            HttpPostedFileBase     oHttpPostedFile     = null;
            MailMessage            mm = new MailMessage();

            if (file.HasFiles)
            {
                for (int n = 0; n < file.Count; n++)
                {
                    oHttpPostedFile = oHttpFileCollection[n];
                    if (oHttpPostedFile.ContentLength <= 0)
                    {
                        continue;
                    }
                    else
                    {
                        uploadedFiles++;
                        var fileName = String.Format("{0}\\{1}", Server.MapPath("~/uploads"), System.IO.Path.GetFileName(oHttpPostedFile.FileName));
                        oHttpPostedFile.SaveAs(fileName);
                        response.Add(System.IO.Path.GetFileName(fileName));

                        //Attachment att = new Attachment( oHttpPostedFile.InputStream, oHttpPostedFile.ContentType);
                        Attachment att = new Attachment(oHttpPostedFile.InputStream, Path.GetFileName(oHttpPostedFile.FileName), oHttpPostedFile.ContentType);
                        mm.Attachments.Add(att);
                    }
                }
            }
            if (uploadedFiles > 0)
            {
                EmailItAlert(mm, Type);
            }


            return(RedirectToAction("Index", "Home"));
        }