后台图片上传以及浮动图片链接怎么做 [b]各位高手们,为什么在后台上传图片的时候,在内网上可以上传,在外网的话就不能上传,欢迎围观,指点迷津;还有就是浮动图片怎么来做,最近在做一个网页改版,需要这方面的知识,谢谢得到高手们的赐教!!! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 浮动图片就是JS广告上传可以用现成的控件using System;using System.Collections.Generic;using System.Linq;using System.Web;using System.Web.UI;using System.Web.UI.WebControls;using System.Data;using System.Data.SqlClient;public partial class _Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } protected void Button1_Click(object sender, EventArgs e) { string name = FileUpload1.FileName;//上传文件名字 string size = FileUpload1.PostedFile.ContentLength.ToString(); string type = FileUpload1.PostedFile.ContentType; string type2 = name.Substring(name.LastIndexOf(".") + 1); string ipath = Server.MapPath("upimg") + "\\" + name; string fpath = Server.MapPath("upfile") + "\\" + name; string path="F:\\aaa\\"+FileUpload1.FileName; string wpath = "upimg\\" + name; if (type2 == "jpg" || type2 == "gif" || type2 == "bmp" || type2 == "png") { FileUpload1.SaveAs("F:\\aaa\\"+FileUpload1.FileName); // Image1.ImageUrl="F:\\aaa\\"+FileUpload1.FileName; Label1.Text = "你传图片的名字是" + name + "<br>文件大小为" + size + "<br>文件类型为" + type2 + "<br>文件路径为" + ipath; } SqlConnection cn = new SqlConnection("server=.;database=Northwind;uid=sa;pwd=sa"); SqlCommand cmd = new SqlCommand("insert into Image(imageName,imagepath) values('" + name + "','" + path + "')", cn); cn.Open(); cmd.ExecuteNonQuery(); cn.Close(); } protected void Button2_Click(object sender, EventArgs e) { SqlConnection cn = new SqlConnection("server=.;database=Northwind;uid=sa;pwd=sa"); SqlCommand cmd = new SqlCommand("select imageName from Image where imageID='" + Convert.ToInt32(TextBox1.Text) + "'", cn); cn.Open(); string a = cmd.ExecuteScalar().ToString(); cn.Close(); Image1.ImageUrl = "F:\\aaa\\" + a; }} 请教 谁用过动易免费版做过网站 有什么限制 有什么后果 心里没底 jquery ajax 提交数据问题 MIS系统中面象对象开发的意义有多大? 图片循环滚动请教 URL伪静态问题. 寻求一种 信息处理方案 抢分的进来啊,我想做一个搜索时进行分词的。 小问题困扰我好久了? 背景音乐 VS.NET2013下EF模板改了吗,怎么生成的类变样了 asp.net mvc renderAction报错 [求助]网站首页悬浮框
上传可以用现成的控件using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{ }
protected void Button1_Click(object sender, EventArgs e)
{
string name = FileUpload1.FileName;//上传文件名字
string size = FileUpload1.PostedFile.ContentLength.ToString();
string type = FileUpload1.PostedFile.ContentType;
string type2 = name.Substring(name.LastIndexOf(".") + 1);
string ipath = Server.MapPath("upimg") + "\\" + name;
string fpath = Server.MapPath("upfile") + "\\" + name;
string path="F:\\aaa\\"+FileUpload1.FileName;
string wpath = "upimg\\" + name;
if (type2 == "jpg" || type2 == "gif" || type2 == "bmp" || type2 == "png")
{
FileUpload1.SaveAs("F:\\aaa\\"+FileUpload1.FileName);
// Image1.ImageUrl="F:\\aaa\\"+FileUpload1.FileName;
Label1.Text = "你传图片的名字是" + name + "<br>文件大小为" + size + "<br>文件类型为" + type2 + "<br>文件路径为" + ipath;
}
SqlConnection cn = new SqlConnection("server=.;database=Northwind;uid=sa;pwd=sa");
SqlCommand cmd = new SqlCommand("insert into Image(imageName,imagepath) values('" + name + "','" + path + "')", cn);
cn.Open();
cmd.ExecuteNonQuery();
cn.Close();
}
protected void Button2_Click(object sender, EventArgs e)
{ SqlConnection cn = new SqlConnection("server=.;database=Northwind;uid=sa;pwd=sa");
SqlCommand cmd = new SqlCommand("select imageName from Image where imageID='" + Convert.ToInt32(TextBox1.Text) + "'", cn);
cn.Open();
string a = cmd.ExecuteScalar().ToString();
cn.Close();
Image1.ImageUrl = "F:\\aaa\\" + a;
}
}