Exemplo n.º 1
0
        private void AsyncFileUpload1UploadedComplete(object sender, AsyncFileUploadEventArgs e)
        {
            string filename = e.FileName;

            if (filename == null)
            {
                return;
            }
            string contentType = AsyncFileUpload1.PostedFile.ContentType;

            if (!contentType.Contains("image"))
            {
                return;
            }
            var fileName = Path.GetFileName(filename);

            if (fileName.Contains(".pdf"))
            {
                AsyncFileUpload1.FailedValidation = true;
                return;
            }
            if (int.Parse(e.FileSize) > 2000000)
            {
                AsyncFileUpload1.FailedValidation = true;
                return;
            }
            string savePath = Page.MapPath(String.Format("~/Avatars/{0}", Path.GetFileName(filename).Replace(" ", "+")));

            ScriptManager.RegisterClientScriptBlock(this, GetType(), "size", "$(function() {top.$get(\"" + uploadResult.ClientID + "\").innerHTML = 'Uploaded size: " + AsyncFileUpload1.FileBytes.Length.ToString() + "';});", true);

            AsyncFileUpload1.SaveAs(savePath);
            _user.Avatar = Path.GetFileName(filename).Replace(" ", "+");
            Members.SaveMember(_user);
        }
Exemplo n.º 2
0
 protected void btnClick_Click(object sender, EventArgs e)
 {
     if (AsyncFileUpload1.HasFile)
     {
         AsyncFileUpload1.SaveAs(@"C:\Drivers\" + AsyncFileUpload1.PostedFile.FileName);
     }
 }
Exemplo n.º 3
0
        protected void AsyncFileUpload1_UploadedComplete(object sender, AsyncFileUploadEventArgs e)
        {
            if (TextBox1.Text != "" && TextBox2.Text != "")
            {
                if (AsyncFileUpload1.HasFile)
                {
                    Session.Clear();
                    Session["checkFile"]  = "FileYes";
                    Session["checkImage"] = "ImageNo";

                    string fileType = AsyncFileUpload1.ContentType;

                    if (fileType == "image/jpeg" || fileType == "image/png")
                    {
                        Session.Clear();
                        Session["checkFile"]  = "FileYes";
                        Session["checkImage"] = "ImageYes";

                        string filename = System.IO.Path.GetFileName(AsyncFileUpload1.FileName);
                        AsyncFileUpload1.SaveAs(Server.MapPath("~/uploads/") + filename);

                        conn.Open();
                        string path = "uploads/" + filename;

                        SqlCommand cmd = new SqlCommand("insert into ElectionInfo values('" + TextBox1.Text + "','" + TextBox2.Text + "', '" + path + " ')", conn);
                        cmd.ExecuteNonQuery();
                        conn.Close();
                    }
                }
            }
        }
Exemplo n.º 4
0
        protected void AsyncFileUpload1_UploadedComplete(object sender, AjaxControlToolkit.AsyncFileUploadEventArgs e)
        {
            string strPath = MapPath("~/upload/") + Path.GetFileName(e.FileName);

            AsyncFileUpload1.SaveAs(strPath);
            displayImage.ImageUrl = strPath;
        }
        protected void FileUploadComplete(object sender, EventArgs e)
        {
            string datetime  = DateTime.Now.ToFileTimeUtc().ToString();
            string filename  = "";
            string filename1 = System.IO.Path.GetFileName(AsyncFileUpload1.FileName);
            String extension = Path.GetExtension(AsyncFileUpload1.FileName);

            filename = datetime + "_" + Session["userid"].ToString() + extension;

            AsyncFileUpload1.SaveAs(Server.MapPath(this.UploadFolderPath) + filename);
            DataTable itemtable = (DataTable)Session["itemtable"];

            itemdr = itemtable.NewRow();

            if (itemtable.Rows.Count < 0)
            {
                itemdr["nid"]      = 1;
                hidfilecount.Value = "1";
            }
            else
            {
                hidfilecount.Value = (Convert.ToInt32(itemtable.Rows.Count) + 1).ToString();
                itemdr["nid"]      = Convert.ToInt32(itemtable.Rows.Count) + 1;
            }
            itemdr["title"]            = txtattachmenttitle.Text;
            itemdr["originalfilename"] = filename1;
            itemdr["uploadfilename"]   = filename;
            itemdr["attachid"]         = "";
            itemtable.Rows.Add(itemdr);

            Session["itemtable"] = itemtable;
            fillattachment();

            btnupload.Visible = true;
        }
Exemplo n.º 6
0
    protected void complete(object sender, AjaxControlToolkit.AsyncFileUploadEventArgs e)
    {
        string[] f1 = AsyncFileUpload1.PostedFile.ContentType.ToString().Split('/');
        int      q  = f1.Length;

        if (!HiddenField2.Value.ToString().Equals(""))
        {
            if (f1[q - 1].Equals("jpg") || f1[q - 1].Equals("jpeg"))
            {
                // MessageBox.Show(lblMessage.Text);
                //  lblMessage.Text = "File uploaded successfully";
                string[] f = AsyncFileUpload1.PostedFile.FileName.Split('.');
                int      i = f.Length;
                int      x = Convert.ToInt32(Application["image"]) + 1;
                Application["image"] = x;
                AsyncFileUpload1.SaveAs(Server.MapPath("~/temp/" + "image" + x.ToString() + "." + f[i - 1]));
                lblMessage.Text   = "File Uploaded Successfully";
                Image1.ImageUrl   = "~/temp/" + "image" + x.ToString() + "." + f[i - 1];
                btnUpload.Enabled = false;
                //  HiddenField1.Value = Image1.ImageUrl;

                UpdatePanel1.Update();
                UpdatePanel2.Update();
                Button2.Visible = true;
            }
        }
    }
Exemplo n.º 7
0
 protected void AsyncFileUpload1_UploadedComplete(object sender, AjaxControlToolkit.AsyncFileUploadEventArgs e)
 {
     if (AsyncFileUpload1.HasFile && e.State == AjaxControlToolkit.AsyncFileUploadState.Success)
     {
         AsyncFileUpload1.SaveAs(Utils.PrepareUserDir(fiName) + e.FileName);
     }
 }
Exemplo n.º 8
0
    void AsyncFileUpload1_UploadedComplete(object sender, AsyncFileUploadEventArgs e)
    {
        ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "size", "top.$get(\"" + uploadResult.ClientID + "\").innerHTML = 'Uploaded size: " + AsyncFileUpload1.FileBytes.Length.ToString() + "';", true);

        // Uncomment to save to AsyncFileUpload\Uploads folder.
        // ASP.NET must have the necessary permissions to write to the file system.
        string extension = Path.GetExtension(AsyncFileUpload1.PostedFile.FileName);
        string filename  = "Applicant-" + applicantID + "-Letter Of Entitlement" + extension;
        string path      = Server.MapPath("/Applicant_Data/applicant-" + applicantID);

        if (!Directory.Exists(path))
        {
            Directory.CreateDirectory(path);
        }
        if (loe != null)
        {
            File.Delete(Server.MapPath(loe));
        }
        AsyncFileUpload1.SaveAs(path + "/" + filename);
        ApplicantReg obj = new ApplicantReg();

        obj.ApplicantID = applicantID;
        obj.saveLOE("Applicant_Data/applicant-" + applicantID + "/" + filename);
        DataSet dset = obj.retrieveData(applicantID);

        loadData(dset);
        //string savePath = MapPath("Uploads/" + Path.GetFileName(e.filename));
        //AsyncFileUpload1.SaveAs(savePath);
    }
Exemplo n.º 9
0
 protected void doUpload(object sender, AjaxControlToolkit.AsyncFileUploadEventArgs e)
 {
     System.Threading.Thread.Sleep(4000);
     if (AsyncFileUpload1.HasFile)
     {
         AsyncFileUpload1.SaveAs(Server.MapPath("~/Upload/" + AsyncFileUpload1.FileName));
     }
 }
Exemplo n.º 10
0
 protected void UploadComplete(object sender, AjaxControlToolkit.AsyncFileUploadEventArgs e)
 {
     if (AsyncFileUpload1.HasFile)
     {
         string FileName  = "img" + Session["UserID"] + AsyncFileUpload1.FileName;
         string ImagePath = Server.MapPath("~") + "PostWall/" + FileName;
         AsyncFileUpload1.SaveAs(ImagePath);
     }
 }
Exemplo n.º 11
0
    //public void UploadHatchesImage_Click(object sender, EventArgs e)
    //{
    //    Project p = new Project();
    //    string sURL = "";
    //    int ProjectID = Convert.ToInt32(ProjectIDHolder.Value);
    //    if (ProjectHatchesPicture.HasFile)
    //    {
    //        sURL = Path.GetFileName(ProjectHatchesPicture.FileName);
    //        sURL = Server.MapPath(".") + "/files/ProjectsFiles/" + sURL;
    //        ProjectHatchesPicture.SaveAs(sURL);
    //        p.UploadHatchesImage(ProjectID, sURL);
    //    }
    //    string sHTML =
    //        "<div id='ProjectHatchesFileHolder' class='FileBlock'>" +
    //            "<a class='DeleteFile pointer glyphicon glyphicon-remove'></a>&nbsp;&nbsp;" +
    //            "<a href='" + sURL + "' target = '_blank'>תרשים פתחים</a>" +
    //        "</div>";
    //    ProjectHatchesPictureContainer.InnerHtml = "";
    //}

    protected void AsyncFileUpload1_UploadedComplete(object sender, AjaxControlToolkit.AsyncFileUploadEventArgs e)
    {
        System.Threading.Thread.Sleep(5000);
        if (AsyncFileUpload1.HasFile)
        {
            string strPath = MapPath("~/files/ProjectsFiles/") + Path.GetFileName(e.FileName);
            AsyncFileUpload1.SaveAs(strPath);
        }
    }
Exemplo n.º 12
0
 protected void AsyncFileUpload1_UploadedComplete(object sender, AjaxControlToolkit.AsyncFileUploadEventArgs e)
 {
     if (AsyncFileUpload1.HasFile)
     {
         String flNameArquivo = AsyncFileUpload1.FileName.Substring(0, AsyncFileUpload1.FileName.LastIndexOf(".")) + DateTime.Now.Hour.ToString() + DateTime.Now.Minute.ToString() + AsyncFileUpload1.FileName.Substring(AsyncFileUpload1.FileName.LastIndexOf("."));
         AsyncFileUpload1.SaveAs(Server.MapPath(this.PathDownloadArquivos + flNameArquivo));
         Session.Add("flNameArquivo", flNameArquivo);
     }
 }
Exemplo n.º 13
0
        protected void FileUploadComplete(object sender, EventArgs e)
        {
            System.IO.Directory.CreateDirectory(Server.MapPath(lblRoot.Text));

            string filename = System.IO.Path.GetFileName(AsyncFileUpload1.FileName);

            AsyncFileUpload1.SaveAs(Server.MapPath(lblRoot.Text + "/") + filename);

            OleDbHelper.ExecuteNonQuery(base.NorthWindConnectionString, CommandType.Text, string.Format("INSERT INTO Media (ProductId, MediaPath) VALUES({0}, '{1}')", lblRoot.Text, filename));
        }
Exemplo n.º 14
0
        void AsyncFileUpload1_UploadedComplete(object sender, AsyncFileUploadEventArgs e)
        {
            ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "size", "top.$get(\"" + uploadResult.ClientID + "\").innerHTML = 'Uploaded size: " + AsyncFileUpload1.FileBytes.Length.ToString() + "';", true);

            //Uncomment to save to AsyncFileUpload\Uploads folder.
            //ASP.NET must have the necessary permissions to write to the file system.

            string savePath = MapPath("~/Dashboard/Uploads/" + Path.GetFileName(e.FileName));

            AsyncFileUpload1.SaveAs(savePath);
        }
    protected void FileUploadComplete(object sender, EventArgs e)
    {
        string savePath = @"F:\BLOG\Projects\InsertData\UploadedFiles\";
        string filename = AsyncFileUpload1.FileName;

        if (AsyncFileUpload1.HasFile)
        {
            savePath += filename;
            AsyncFileUpload1.SaveAs(savePath);
        }
    }
Exemplo n.º 16
0
    protected void ProcessUpload(object sender, AjaxControlToolkit.AsyncFileUploadEventArgs e)
    {
        ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "size", "top.$get(\"" + uploadResult.ClientID + "\").innerHTML = 'Uploaded size: " + AsyncFileUpload1.FileBytes.Length.ToString() + "';", true);
        string fileName = Server.MapPath("./") + "photos\\" + Session["username"] + "image.jpg";

        AsyncFileUpload1.FileName.ToString();
        AsyncFileUpload1.SaveAs(fileName);
        ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "image", "top.$get(\"photo\").src = 'photos/" + Session["username"] + "image.jpg" + "';", true);
        //  ScriptManager.RegisterClientScriptBlock(AsyncFileUpload1, AsyncFileUpload1.GetType(), "img",
        //      "top.document.getElementById('photos').src='"+fileName+"';",
        //      true);
    }
Exemplo n.º 17
0
        protected void ProcessUpload(object sender, AjaxControlToolkit.AsyncFileUploadEventArgs e)
        {
            var filename = System.IO.Path.GetFileName(AsyncFileUpload1.FileName);


            var i = UserManager.Instance.UpdateUserProfile(AsyncFileUpload1.FileName, "AjUserImage", objSecurePage.LoggedInUserId);

            if (i > 0)
            {
                AsyncFileUpload1.SaveAs(Server.MapPath(new Common().GetFilepath("UserImage")) + filename);
            }
        }
Exemplo n.º 18
0
    //protected void lnkUpload_Click(object sender, EventArgs e)
    //{
    //    //if (fileupload1.PostedFile != null)
    //    //{
    //    //    string FileName = Path.GetFileName(fileupload1.PostedFile.FileName);

    //    //    //Save files to disk
    //    //    fileupload1.SaveAs(Server.MapPath("../ProductImages/" + FileName));


    //    //    Medicine_In_Stock mis = new Medicine_In_Stock
    //    //    {
    //    //        Image = "../ProductImages/" + FileName
    //    //    };
    //    //    dc.Medicine_In_Stocks.InsertOnSubmit(mis);
    //    //    dc.SubmitChanges();
    //    //    //BindGridDataMedicine();

    //    //}
    //    //else
    //    //{
    //    //    //lblMessage.ForeColor = System.Drawing.Color.Red;
    //    //    lblerr.Text = "File format not recognised." + " Upload Image/Word/PDF/Excel formats";
    //    //}
    //}
    protected void AsyncFileUpload1_UploadedComplete(object sender, AjaxControlToolkit.AsyncFileUploadEventArgs e)
    {
        string filename = System.IO.Path.GetFileName(AsyncFileUpload1.FileName);

        AsyncFileUpload1.SaveAs(Server.MapPath("../ProductImages/") + filename);
        Medicine_In_Stock mis = new Medicine_In_Stock
        {
            Image = "../ProductImages/" + filename
        };

        dc.Medicine_In_Stocks.InsertOnSubmit(mis);
        dc.SubmitChanges();
    }
Exemplo n.º 19
0
    protected void FileUploadComplete(object sender, AjaxControlToolkit.AsyncFileUploadEventArgs e)
    {
        if (AsyncFileUpload1.HasFile)
        {
            var fileName      = AsyncFileUpload1.FileName;
            var fileExtension = fileName.Substring(fileName.LastIndexOf('.') + 1);
            if (fileExtension.ToLower().Contains("jpg") || fileExtension.ToLower().Contains("png"))
            {
                if (AsyncFileUpload1.FileContent.Length < 2000000)
                {
                    String savePath = MapPath("profilePics/" + AsyncFileUpload1.FileName);

                    string formnum = "";

                    string origPath = MapPath("profilePics/" + formnum + ".jpg");
                    AsyncFileUpload1.SaveAs(origPath);
                    // File.AppendAllText("C:/lg.txt", "\r\n"+savePath);
                    AsyncFileUpload1.SaveAs(savePath);

                    var image = new Bitmap(MapPath("profilePics/" + formnum + ".jpg"));
                    if (image.Height > 200 || image.Width > 200)
                    {
                        Console.Write("IMAGE DIMENSION LARGE PROCESSING IMAGE");
                        //var image2 = ResizeImage(image, 200, 200);
                        //image.Dispose();
                        //image = null;
                        //File.Delete(origPath);
                        //image2.Save(origPath);
                        //image2.Dispose();
                        //image2 = null;
                    }
                    else
                    {
                        //Console.Write("IMAGE DIMENSION SMALL SKIPPING IMAGE");
                        image.Dispose();
                        image = null;
                    }

                    // AsyncFileUpload1.SaveAs(MapPath("C:/AdmissionPortal/Students/profilePics/" + AsyncFileUpload1.FileName));
                    //   literealErrorImage.Text = "";
                    UploadFolderPath = "profilePics/";
                    ViewState["imageDisplay_str"] = formnum + "." + fileExtension;
                }
                else
                {
                    ClearContents(sender as Control);
                    //   literealErrorImage.Text = " <span class=\"btn btn-danger\">Image file size should be less than 2 MB </span>";
                }
            }
        }
    }
    protected void AsyncFileUpload1_UploadedComplete(object sender, AjaxControlToolkit.AsyncFileUploadEventArgs e)
    {
        string filename      = System.IO.Path.GetFileName(AsyncFileUpload1.FileName);
        string FileFolder    = Request.QueryString["FolderPath"].ToString();
        string FileName_Spec = Request.QueryString["FileName"];

        if (FileName_Spec != null || FileName_Spec != "")
        {
            filename = FileName_Spec + "." + filename.Split('.')[1];
        }

        AsyncFileUpload1.SaveAs(Server.MapPath("~" + FileFolder) + filename);

        Session["FileName"] = "~" + FileFolder + filename;
    }
Exemplo n.º 21
0
        //protected void UpdateDetails_Click(object sender, EventArgs e)
        //{

        //   // string query = "update tbl_users set UserName='******',Password='******',Email='" + TextBox10.Text + "' where EnrollNo='" + UserEnrollNo + "' ";
        //    //conc.ExecuteQuery(query);

        //    conc.ExecuteQuery(query);
        //}

        //protected void btnSendMsg_Click(object sender, EventArgs e)
        //{

        //    //HttpPostedFile postedFile = Request.Files["attachFile"];
        //    //if(postedFile != null && postedFile.ContentLength > 0)
        //    //{
        //    //    string filePath = Server.MapPath("~/uploads/") + Path.GetFileName(postedFile.FileName);
        //    //    postedFile.SaveAs(filePath);
        //    //    int fileSize = postedFile.ContentLength;
        //    //    if(fileSize > 2097152)
        //    //    {

        //    //    }
        //    //    else
        //    //    {

        //    //    }

        //    //}
        //    if (FileUpload1.HasFile)
        //    {
        //        string filePath = Server.MapPath("~/uploads/") + Path.GetFileName(FileUpload1.FileName);
        //         FileUpload1.SaveAs(filePath);
        //    }



        //}


        protected void FileUploadComplete(object sender, EventArgs e)
        {
            System.Threading.Thread.Sleep(1000);
            string filename = System.IO.Path.GetFileName(AsyncFileUpload1.FileName);

            //var extension = Path.GetExtension(filename);
            //string fileName = string.Format("{0}-{1:ddMMMyyyy-HHmm}" + extension, this.UploadFolderPath, DateTime.Now);
            //var extension = Path.GetExtension(filename);
            //var newName = filename.Replace(filename, extension) + DateTime.Now.ToString("yyyy-MM-dd HH:mm:dd") + extension;

            // filename = filename + DateTime.Now.ToString("hh:mm tt");


            AsyncFileUpload1.SaveAs(Server.MapPath(this.UploadFolderPath) + filename);
        }
Exemplo n.º 22
0
 protected void AsyncFileUpload1_UploadedComplete(object sender, AjaxControlToolkit.AsyncFileUploadEventArgs e)
 {
     if (AsyncFileUpload1.HasFile)
     {
         if (!AsyncFileUpload1.ContentType.Contains("image"))
         {
             ScriptManager.RegisterStartupScript(Page, Page.GetType(), Guid.NewGuid().ToString(), "alert('Tipo de iamgem inválido');", true);
         }
         else
         {
             String flName = AsyncFileUpload1.FileName.Substring(0, AsyncFileUpload1.FileName.LastIndexOf(".")) + DateTime.Now.Hour.ToString() + DateTime.Now.Minute.ToString() + AsyncFileUpload1.FileName.Substring(AsyncFileUpload1.FileName.LastIndexOf("."));
             AsyncFileUpload1.SaveAs(Server.MapPath(this.PathDownloadArquivos + flName));
             Session.Add("flNameNoticia", flName);
         }
     }
 }
Exemplo n.º 23
0
        void AsyncFileUpload1_UploadedComplete(object sender, AsyncFileUploadEventArgs e)
        {
            try
            {
                string path    = "";
                string urlFile = "";
                if (Path.GetExtension(e.filename).Contains(".pdf") == false && Path.GetExtension(e.filename).Contains(".zip") && Path.GetExtension(e.filename).Contains(".rar"))
                {
                    return;
                }
                SqlFunction sqlFun = new SqlFunction(HttpContext.Current.Session.GetConnectionString2());
                //lấy mã dự án
                //string maDuAn = sqlFun.GetOneStringField("select maDuAn from tblDuAn where sttDuAnpr = N'" + hdfSttDA.Value + "'");
                string tenFile = e.filename;//"VanBan" + hdfSTTVanBan.Value + ".pdf";
                if (!System.IO.Directory.Exists(Server.MapPath("~/VanBan/" + HttpContext.Current.Session.GetDonVi().maDonVi + "/" + userControlVanBanChucNang.Value.ToString().Split('_')[0].ToString())))
                {
                    System.IO.Directory.CreateDirectory(Server.MapPath("~/VanBan/" + HttpContext.Current.Session.GetDonVi().maDonVi + "/" + userControlVanBanChucNang.Value.ToString().Split('_')[0].ToString()));
                }
                string strDate       = DateTime.Now.ToString("dd_MM_yy_hhmmss");
                string fileExtension = Path.GetExtension(tenFile).Replace(".", "");
                tenFile = tenFile.Substring(tenFile.LastIndexOf("\\\\") + 1);
                tenFile = tenFile.Substring(0, tenFile.LastIndexOf(fileExtension)) + strDate + "." + fileExtension;
                tenFile = tenFile.Replace(" ", "");
                path    = string.Concat(Server.MapPath("/VanBan/" + HttpContext.Current.Session.GetDonVi().maDonVi + "/" + userControlVanBanChucNang.Value.ToString().Split('_')[0].ToString() + "/" + tenFile + ""));

                if (!System.IO.File.Exists(path))
                {
                    System.IO.File.Delete(path);
                    AsyncFileUpload1.SaveAs(path);
                    urlFile = "/VanBan/" + HttpContext.Current.Session.GetDonVi().maDonVi + "/" + userControlVanBanChucNang.Value.ToString().Split('_')[0].ToString() + "/" + tenFile + "";
                    sqlFun.ExeCuteNonQuery("UPDATE dbo.tblVanBanDA SET tenFile=N'" + urlFile + "' WHERE sttVBDApr='" + userControlVanBanpr.Value.ToString() + "'");
                    AsyncFileUpload1.ClearState();
                    AsyncFileUpload1.Dispose();
                    return;
                }
                else
                {
                    //Xoa file neu da ton tai
                    System.IO.File.Delete(path);
                    AsyncFileUpload1_UploadedComplete(sender, e);
                }
            }
            catch
            {
            }
            AsyncFileUpload1.Dispose();
        }
Exemplo n.º 24
0
    }//page load

    protected void FileUploadComplete(object sender, EventArgs e)
    {
        Usuario objUsuario = ((Usuario)Session["usuario"]);
        //string filename = System.IO.Path.GetFileName(AsyncFileUpload1.FileName);
        string extension = Path.GetExtension(AsyncFileUpload1.FileName);
        string filename = (objUsuario.IdUsuario.ToString() + extension);
        AsyncFileUpload1.SaveAs(Server.MapPath("/FotosPerfil/") + filename);
        //grava a foto no colunista pois lá é usado foto+id como referencia, e aqui é nome+id
        //string colunista = ("foto" +objUsuario.IdUsuario.ToString() + extension);
        //AsyncFileUpload1.SaveAs(Server.MapPath("/colunista/images/colunistas/") + colunista);
        //fim do gravar colunista
        PerfilBD perfilbd = new PerfilBD();
        objUsuario.PerfilC.FotoPerfil = "/FotosPerfil/" + filename;
        perfilbd.Update(objUsuario);


    }
Exemplo n.º 25
0
        // for file upload
        //protected void ImageUpload(string temp)
        //{
        //    if (FileUpload1.PostedFile != null)
        //    {

        //        string FileName = Path.GetFileName(FileUpload1.PostedFile.FileName);

        //        //Save files to disk
        //        FileUpload1.SaveAs(Server.MapPath("images/" + FileName));

        //        SqlConnection con = new SqlConnection("Data Source=itksqlexp8;Integrated Security=true");

        //        try
        //        {

        //            con.Open();
        //            // con.ChangeDatabase("nasa_SilentAuction_v1"); // change itk368XXXX to your ID here
        //            //                        dbConnection.ChangeDatabase("368SQLDB");

        //            string strQuery = "Update item SET filePath = @filePath where itemID = \'" + temp + "\'";
        //            SqlCommand cmd = new SqlCommand(strQuery, con);
        //            // cmd.Parameters.AddWithValue("@ImageID", ImageID);
        //            // cmd.Parameters.AddWithValue("@FileName", FileName);
        //            cmd.Parameters.AddWithValue("@filePath", "images/" + FileName);
        //            cmd.CommandType = CommandType.Text;
        //            cmd.Connection = con;

        //            // con.Open();
        //            cmd.ExecuteNonQuery();

        //            lblStatus.Text = "Image sucessfully uploaded";
        //        }

        //        catch (Exception ex)
        //        {
        //            Response.Write(ex.Message);
        //        }

        //        finally
        //        {
        //            con.Close();
        //            con.Dispose();
        //        }
        //    }

        //}



        protected void AsyncFileUpload1_UploadedComplete(object sender, AjaxControlToolkit.AsyncFileUploadEventArgs e)

        {
            string id_item = (string)Session["itemid"];

            System.Threading.Thread.Sleep(3000);

            string filename = System.IO.Path.GetFileName(AsyncFileUpload1.FileName);

            AsyncFileUpload1.SaveAs(Server.MapPath("~/CommonImages/") + filename);
            System.Threading.Thread.Sleep(3000);

            SqlConnection con = new SqlConnection("Data Source=itksqlexp8;Integrated Security=true");

            try
            {
                con.Open();
                con.ChangeDatabase("nasa_SilentAuction_v1"); // change itk368XXXX to your ID here
                //                        dbConnection.ChangeDatabase("368SQLDB");

                string     strQuery = "Update item SET filePath = @filePath where itemID = \'" + id_item + "\'";
                SqlCommand cmd      = new SqlCommand(strQuery, con);
                // cmd.Parameters.AddWithValue("@ImageID", ImageID);
                // cmd.Parameters.AddWithValue("@FileName", FileName);
                cmd.Parameters.AddWithValue("@filePath", "~/CommonImages/" + filename);
                cmd.CommandType = CommandType.Text;
                cmd.Connection  = con;

                // con.Open();
                cmd.ExecuteNonQuery();

                lblStatus.Text = "Image sucessfully uploaded";
            }

            catch (Exception ex)
            {
                Response.Write(ex.Message);
            }

            finally
            {
                con.Close();
                con.Dispose();
            }
        }
Exemplo n.º 26
0
 protected void AsyncFileUpload1_UploadedComplete(object sender, AjaxControlToolkit.AsyncFileUploadEventArgs e)
 {
     if (AsyncFileUpload1.HasFile)
     {
         string fileExtend = System.IO.Path.GetExtension(AsyncFileUpload1.FileName).ToLower();
         if (fileExtend == ".jpg" || fileExtend == ".png")
         {
             string file = string.Format(@"{0}\{1}", Server.MapPath(".") + "\\Uploads", System.Guid.NewGuid() + fileExtend);
             try
             {
                 AsyncFileUpload1.SaveAs(file);
                 System.Threading.Thread.Sleep(3600);
             }
             catch
             { }
         }
     }
 }
Exemplo n.º 27
0
    protected void AsyncFileUpload1_UploadedComplete(object sender, AjaxControlToolkit.AsyncFileUploadEventArgs e)
    {
        // Save file
        string filename = System.IO.Path.GetFileName(AsyncFileUpload1.FileName);

        filename = String.Format("TYM_{0}_FORCAST_{1}", DateTime.Now.ToString("yyyyMMddHHmmss"), filename);
        AsyncFileUpload1.SaveAs(Server.MapPath("~/Files/") + filename);

        // HATC Order
        string CustCode = "40103010";

        filename = Server.MapPath("~/Files/") + filename;
        if (File.Exists(filename))
        {
            string line = string.Empty;
            using (StreamReader sr = new StreamReader(filename))
            {
                using (SqlProcedure sp = new SqlProcedure("sp_TYM_Forcast_ClearData"))
                {
                    sp.ExecuteNonQuery();
                }
                while ((line = sr.ReadLine()) != null)
                {
                    if (line.Length > 0)
                    {
                        MyCompany.Data.Objects.TYMForcastImport Order = new MyCompany.Data.Objects.TYMForcastImport();
                        Order.OrderBy             = CustCode;
                        Order.DeliveryDestination = "";
                        Order.CustomerMatCode     = line.Substring(0, 3) + "-" + line.Substring(3, 5) + "-" + line.Substring(8, 2) + "-" + line.Substring(10, 2) + "-" + line.Substring(12, 2) + "-" + line.Substring(14, 4) + "-" + line.Substring(18, 4);//line.Substring(0, 22);
                        Order.PartsDevision       = "1";
                        Order.CustomerPO          = "";
                        Order.ReliabilityDevision = "P";
                        Order.DeliveryDate        = Convert.ToDateTime(line.Substring(22, 4).Trim() + "-" + line.Substring(26, 2).Trim() + "-" + line.Substring(28, 2).Trim());
                        Order.Quantity            = float.Parse(line.Substring(30, 8)).ToString().Trim();
                        Order.Unit       = "ST";
                        Order.PlngPeriod = "D";
                        Order.SAPCode    = "";//SharedBusinessRules.getSAPCode(Order.CustomerMatCode);
                        Order.Insert();
                    }
                }
                sr.Close();
            }
        }
    }
Exemplo n.º 28
0
        protected void UploadComplete(object sender, AjaxControlToolkit.AsyncFileUploadEventArgs e)
        {
            if (AsyncFileUpload1.HasFile)
            {
                try
                {
                    string categoryID = Request.QueryString["CategoryID"];
                    string FileName   = "img" + Session["UserID"] + AsyncFileUpload1.FileName;
                    string ImagePath  = Server.MapPath("~") + "PostWall/" + FileName;
                    AsyncFileUpload1.SaveAs(ImagePath);

                    Cs_Gallary cs_Gallary = new Cs_Gallary();
                    cs_Gallary.AddGalary(Convert.ToString(Session["UserID"]), FileName, categoryID);
                }
                catch (Exception ex)
                {
                }
            }
        }
        protected void FileUploadComplete(object sender, EventArgs e)
        {
            //String extension = Path.GetExtension(System.IO.Path.GetFileName(AsyncFileUpload1.FileName));
            //if (extension.ToUpper() != ".JPG" && extension.ToUpper() != ".JPEG" && extension.ToUpper() != ".PNG" && extension.ToUpper() != ".GIF")
            //{
            //    ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "temp", "<script type='text/javascript'>alert('Selected file  has invalid format');</script>", false);
            //    return;
            //}

            //string filename = DateTime.Now.ToFileTimeUtc().ToString()+extension;
            //AsyncFileUpload1.SaveAs(Server.MapPath(this.UploadFolderPath) + filename);
            //strfilename = filename;
            //Session["filename"] = filename;

            string filename = System.IO.Path.GetFileName(AsyncFileUpload1.FileName);

            AsyncFileUpload1.SaveAs(Server.MapPath(this.UploadFolderPath) + filename);
            Session["filename"] = filename;
        }
 //protected void AjaxFileUploadEvent(object sender, AjaxFileUploadEventArgs e)
 //{
 //    string filename = System.IO.Path.GetFileName(e.FileName);
 //    const string strUploadPath = "~/Upload/";
 //    AjaxFileUpload11.SaveAs(Server.MapPath(strUploadPath) + filename);
 //}
 protected void FileUploadComplete(object sender, AsyncFileUploadEventArgs e)
 {
     if (Session["login"] != null && Session["UserName"] != null)
     {
         if ((bool)Session["login"])
         {
             if (!Directory.Exists(UploadFolderPath + Session["FullName1"]))
             {
                 string path = Server.MapPath(UploadFolderPath + Session["FullName1"] + "");
                 Directory.CreateDirectory(path);
                 string filename = Path.GetFileName(AsyncFileUpload1.FileName);
                 AsyncFileUpload1.SaveAs(Server.MapPath(UploadFolderPath) + Session["FullName1"] + "/" + filename);
                 UpdateValueImg(UploadFolderPath + Session["FullName1"] + "/" + filename);
             }
             else
             {
                 string filename = Path.GetFileName(AsyncFileUpload1.FileName);
                 AsyncFileUpload1.SaveAs(Server.MapPath(UploadFolderPath) + Session["FullName1"] + "/" + filename);
                 UpdateValueImg(UploadFolderPath + Session["FullName1"] + "/" + filename);
             }
         }
     }
 }