Esempio n. 1
0
        public contentUpload uploaderFile(AsyncFileUpload fileUpload)
        {
            List <string> errorMessage = new List <string>();
            List <string> fileExt      = new List <string>();

            contentUpload cu = new contentUpload();

            fileExt.Add(".jpg");
            fileExt.Add(".png");

            if (fileUpload.PostedFile.ContentLength >= 100000)
            {
                errorMessage.Add("file terlalu besar, maximal 100 kb");
            }

            if (!fileExt.Contains(System.IO.Path.GetExtension(fileUpload.FileName)))
            {
                errorMessage.Add("hanya file jpg atau png yang diperbolehkan");
            }

            if (errorMessage.Count == 0)
            {
                fileUpload.SaveAs(Server.MapPath("Files/") +
                                  Guid.NewGuid().ToString() +
                                  System.IO.Path.GetExtension(fileUpload.FileName));

                cu.fileName = Server.MapPath("Files/") +
                              Guid.NewGuid().ToString() +
                              System.IO.Path.GetExtension(fileUpload.FileName);
            }

            return(cu);
        }
Esempio n. 2
0
 protected void tiketUploadComplete(object sender, AsyncFileUploadEventArgs e)
 {
     try
     {
         contentUpload uploaded = uploaderFile(tiketUpload);
         if (!string.IsNullOrEmpty(uploaded.fileName) && uploaded.errorMessage == null)
         {
         }
         else
         {
             throw new ArgumentException("the first argument cannot be less than the second");
         }
     }
     catch (Exception)
     {
         throw;
     }
 }
Esempio n. 3
0
 protected void airporttaxUploadComplete(object sender, AsyncFileUploadEventArgs e)
 {
     try
     {
         contentUpload uploaded = uploaderFile(airporttaxUpload);
         if (!string.IsNullOrEmpty(uploaded.fileName) && uploaded.errorMessage == null)
         {
         }
         else
         {
             throw new ArgumentException("the first argument fail");
         }
     }
     catch (Exception)
     {
         throw;
     }
 }