Ejemplo n.º 1
0
    protected void AjaxFileUpload1_OnUploadComplete(object sender, AjaxFileUploadEventArgs file)
    {
        try
        {
            Byte[] fileBytes  = file.GetContents();
            string sPath      = Server.MapPath("\\" + System.Configuration.ConfigurationManager.AppSettings["APP_NAME"].ToString() + "\\uploads\\Vetting\\VetRAtt");
            Guid   GUID       = Guid.NewGuid();
            string AttachPath = "VET_" + GUID.ToString() + Path.GetExtension(file.FileName);



            objBLLIndx.VET_Ins_ResponseAttachment(UDFLib.ConvertToInteger(Response_ID), Path.GetFileName(file.FileName), AttachPath, Convert.ToInt32(Session["userid"].ToString()));

            string     FullFilename = Path.Combine(sPath, AttachPath);
            FileStream fileStream   = new FileStream(FullFilename, FileMode.Create, FileAccess.ReadWrite);
            fileStream.Write(fileBytes, 0, fileBytes.Length);
            fileStream.Close();
            LoadAttachment(ViewState["Response_ID"].ToString());
            string jsSqlError2 = "alert('Attachment saved successfully.');";
            ScriptManager.RegisterStartupScript(this, this.GetType(), "jsSqlError2", jsSqlError2, true);
        }
        catch (Exception ex)
        {
            UDFLib.WriteExceptionLog(ex);
            string js = "alert('" + UDFLib.GetException("SystemError/ GeneralMessage") + "');";
            ScriptManager.RegisterStartupScript(this, this.GetType(), "error", js, true);
        }
    }