62,272
社区成员
发帖
与我相关
我的任务
分享
//下载
string path = Server.MapPath(dr["imagePath"]);
FileInfo file = new FileInfo(path);
Response.Clear();
Response.AddHeader("content-disposition", "attachment;filename=" + HttpUtility.UrlEncode((file.Name), System.Text.Encoding.UTF8));
Response.AddHeader("content-length", file.Length.ToString());
Response.ContentType = "application/octet-stream";
Response.WriteFile(file.FullName);
Response.Flush();
Response.Close();
Response.End();
string path = "upload/"+filename;//这个就是你的图片路径
protected void upload_Click(object sender, EventArgs e)
{
if (upfile.HasFile)
{
string fname = upfile.PostedFile.FileName;
int fi = fname.LastIndexOf("\\") + 1;
string filename = fname.Substring(fi);
string path = "upload/filename";//这个就是你的图片路径
upfile.PostedFile.SaveAs(Server.MapPath(path));
string strSql = "insert into table(imagePath) values(@imagePath)";
Sqlparameter[] para = {new sqlparameter("@imagePath",sqldbtype.varchar,100)};
para[0].value=path;
if(sqlhelper.ExecuteNonquery(strSql,para)==1)
Response.Write("<script>alert('报名表上传成功!');</script>");
else
Response.Write("<script>alert('报名表上传失败!');</script>");
}
else
{
Response.Write("<script>alert('请选择您要上传的报名表!');</script>");
}
}