上傳文件后,前臺的訪問問題

protected void Button2_Click(object sender, EventArgs e)
        {
            string strLogoName = "nologo.jpg";
            string strURL = this.TextLink.Text.ToString().Trim();

            if (RadioButtonList1.SelectedIndex==1)
            {
                string strLinkPath = Server.MapPath("../Images/Link");
                strLogoName = "Link" + System.DateTime.Now.Ticks;
                strLogoName += FileUpload1.FileName.Substring(FileUpload1.FileName.LastIndexOf("."));
                FileUpload1.SaveAs(strLinkPath + "//" + strLogoName);
            }
            else if (RadioButtonList1.SelectedIndex==0)
            {
                strLogoName = this.txtHTTPLogo.Text.ToString().Trim();
            }

            SqlParameter[] arrParameter = new SqlParameter[3];
            arrParameter[0] = new SqlParameter("@Linkname ", SqlDbType.VarChar, 50);
            arrParameter[0].Value = Convert.ToString(this.TextWord.Text.ToString().Trim());
            arrParameter[1] = new SqlParameter("@wordLink ", SqlDbType.VarChar, 500);
            arrParameter[1].Value = strURL;
            arrParameter[2] = new SqlParameter("@PictureLink ", SqlDbType.VarChar, 200);
            arrParameter[2].Value = strLogoName;
            if (Convert.ToInt32(Sport.SqlHelper.ExecuteNonQuery(Sport.SysConfig.GetConnection(), CommandType.StoredProcedure, "P_InsertLink", arrParameter)) > 0)
            {
                this.Label1.Visible = true;
                this.Label1.Text = "添加鏈接成功!";
            }
            else
            {
                this.Label1.Visible = true;
                this.Label1.Text = "添加鏈接失敗!";
            }
            this.LinkDataBind();
            this.TextLink.Text = String.Empty;
            this.TextWord.Text = String.Empty;
            this.txtHTTPLogo.Text = String.Empty;
        }

 

通過以上程序提交以後 ,數據庫裏面就只有文件名,而沒有完整路徑,要訪問的時候,根據你的程序直接寫就行了

比如數據庫中是a.jpg

那麽路徑就可能是string path="../images/a.jpg";

img.ImgaeUrl=path;

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值