admin/musicup.aspx.cs

(开头部分) 3KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.IO;
using System.Data;
using System.Data.SqlClient;

public partial class admin_musicup : System.Web.UI.Page
{
    DBhelper db = new DBhelper();
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            if (Session["Name"] == null)
            {
                Response.Redirect("../main.aspx");              
            }
            if (MusicUp.FileName != string.Empty)
            {
                TextMusic.Text = MusicUp.FileName.Substring(MusicUp.FileName.Length - MusicUp.FileName.IndexOf("."));
            }
            Bind();
        }
    }
    protected void Bind()
    {       
         string sql = "select * from Music";
            GdMusic.DataSource = db.GetDataSet(sql,"Music");
            GdMusic.DataBind();
    }
    protected void GdMusic_RowDeleting(object sender, GridViewDeleteEventArgs e)
    {
        string sql = "delete from Music where MusicID=" + GdMusic.Rows[e.RowIndex].Cells[0].Text;     
        string Exid = "select MusicPath from Music where MusicID=" + GdMusic.Rows[e.RowIndex].Cells[0].Text;
        string MusicPath = db.ExecScalar(Exid);
        DBhelper.DoSql(sql);
        string dpath = Server.MapPath(@"" + MusicPath + "");
        System.IO.File.Delete(dpath);//删除文件             
        Common.ShowMsgAndRedirect("删除成功", this.Page, "musicup.aspx");
        Bind();
    }
    protected void BtUp_Click(object sender, EventArgs e)
    {
        string TimeName = DateTime.Now.ToString("yyyyMMddhhmmss");
        DateTime dt = DateTime.Now;
        if (MusicUp.PostedFile.FileName != string.Empty)
        {
            if (MusicUp.PostedFile.ContentLength < 10485760)
            {
                string fname = MusicUp.FileName;
                string filetype = fname.Substring(fname.LastIndexOf(".") + 1).ToLower(); //获取文件的后缀名
                string fileupname=fname.Substring(fname.Length-fname.IndexOf("."));
                string filename = TimeName + fname.Substring(fname.LastIndexOf('.'), fname.Length - fname.LastIndexOf('.'));
                if (filetype == "mp3")
                {
                    string uppath = Server.MapPath("~/mp3/") + filename;
后面还有 32 行代码,解锁后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明

AI 解读

登录后可用,每次 10 积分,解读结果公开显示在下面。

还没有人解读过这个文件。