Exemplo n.º 1
0
        protected void Button2_Click(object sender, EventArgs e)
        {
            if (FileUpload1.HasFile) //method to upload files. from Sir kudvenkat's tutorials
            {
                string filename = FileUpload1.PostedFile.FileName;
                var path = new Upload(filename);
                string loc = path.FilePath().ToString();
                string fileext = Path.GetExtension(FileUpload1.FileName);

                if (fileext.ToLower() != ".pdf" && fileext.ToLower() != ".ppt" && fileext.ToLower() != ".pptx" && fileext.ToLower() != ".doc" && fileext.ToLower() != ".docx") //check for file formats
                {
                    lbl_upload.Text = "Only .pdf , .ppt , .pptx , .doc , .docx documents are allowed";
                    lbl_upload.ForeColor = System.Drawing.Color.Red;
                }
                else //check for file size
                {
                    int filesize = FileUpload1.PostedFile.ContentLength;
                    if (filesize > 25165824)
                    {
                        lbl_upload.Text = "Files greater than 12 MB are not allowed < /br> You can email us the source if you wish :)";
                        lbl_upload.ForeColor = System.Drawing.Color.Red;
                    }
                    else //if everything is cool, upload the file
                    {
                        FileUpload1.PostedFile.SaveAs(Server.MapPath("~/Uploads/default/") + FileUpload1.FileName);
                        lbl_upload.Text = "File Uploaded";
                        lbl_upload.ForeColor = System.Drawing.Color.Green;
                    }
                }
            }
           
        }
Exemplo n.º 2
0
        void Button1_Click(object sender, EventArgs e)
        {
            Upload up = new Upload();

            up.header           = new Helper.Web.UploadSoapHeader();
            up.header.AppID     = "1";
            up.header.Algorithm = "md5";
            up.header.Signature = up.CreateSignature(up.header.AppID + up.header.Algorithm + "key1", "md5", "key1");

            Helper.Web.UploadResult rs = up.Upload(new Helper.Web.UploadRequest()
            {
                SaveVirtualPath = "Styles",
                FileBytes       = FileUpload1.FileBytes,
                FileName        = FileUpload1.FileName
            });

            Response.Write(rs.Code + "," + rs.Msg + "," + rs.ReturnFilePath);
        }