构建网站图片上传不上去
2011-05-11 18:18
99 查看
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Colo.BLL;
using Colo.Entity;
using Web.PageBase.Utility;
using Colo.Web.code;
using System.Text;
namespace Colo.Web.admin.Products
{
public partial class ProPicAdmin : AdminPage
{
public string colorhtml = string.Empty;
protected void Page_Load(object sender, EventArgs e)
{
if (this.IsHttpPost)
{
if (!string.IsNullOrEmpty(Request.Form["id"]))
{
UpFileImg.DeleteImg(Request.Form["imgurl"].ToString());
ColoProPicBLL.DeleteProPicByID(Convert.ToInt32(Request.Form["id"]));
Page.ClientScript.RegisterStartupScript(this.GetType(), "m", "alert('删除成功');location.href='propicadmin.aspx?id=" + this.pid.Value + "'", true);
}
if (!string.IsNullOrEmpty(Request.Form["op"]))
{
if (Request.Form["op"].ToString() == "1")//设置产品封面
{
int proid = Convert.ToInt32(Request.Form["proid"]);
int picid = Convert.ToInt32(Request.Form["picid"]);
ColoProPicBLL.SetTopPic(proid, picid);
Page.ClientScript.RegisterStartupScript(this.GetType(), "m", "alert('产品封面设置成功!');location.href='propicadmin.aspx?id=" + this.pid.Value + "'", true);
}
}
}
else
{
if (!string.IsNullOrEmpty(Request.QueryString["id"]))
{
int id = Convert.ToInt32(Request.QueryString["id"]);
ProPicBind(id, 0);
// ProColorBind(id);
}
}
}
protected void ProPicBind(int id, int colorid)
{
ColoProModel p = ColoProBLL.GetProByID(id);
this.txtProName.Text = p.F_ProName;
this.pid.Value = id.ToString();
List<ColoProPicModel> list = ColoProPicBLL.GetProPicList(id, colorid);
PhotoList.DataSource = list;
PhotoList.DataBind();
}
protected void btnUpload_Click(object sender, EventArgs e)
{
string[] filePath = new string[5];
string[] samllpic = new string[5];
int count = 0;
if (!string.IsNullOrEmpty(this.File1.Value))
{
filePath[0] = "Upload/" + UpFileImg.UpLoad(this.File1, Server.MapPath("/UpLoad"));
samllpic[0] = "Upload/small/" + UpFileImg.MakeThumbnail(File1.PostedFile.FileName, Server.MapPath("/UpLoad//small"), 110, 80, "Cut");
// PhotoBLL.ADD(Convert.ToInt32(this.classid.Value), filePath[0]);
count++;
}
if (!string.IsNullOrEmpty(this.File2.Value))
{
filePath[1] = "Upload/" + UpFileImg.UpLoad(this.File2, Server.MapPath("/UpLoad"));
samllpic[1] = "Upload/small/" + UpFileImg.MakeThumbnail(File2.PostedFile.FileName, Server.MapPath("/UpLoad//small"), 110, 80, "Cut");
// PhotoBLL.ADD(Convert.ToInt32(this.classid.Value), filePath[1]);
count++;
}
if (!string.IsNullOrEmpty(this.File3.Value))
{
filePath[2] = "Upload/" + UpFileImg.UpLoad(this.File3, Server.MapPath("/UpLoad"));
samllpic[2] = "Upload/small/" + UpFileImg.MakeThumbnail(File3.PostedFile.FileName, Server.MapPath("/UpLoad//small"), 110, 80, "Cut");
// PhotoBLL.ADD(Convert.ToInt32(this.classid.Value), filePath[2]);
count++;
}
if (!string.IsNullOrEmpty(this.File4.Value))
{
filePath[3] = "Upload/" + UpFileImg.UpLoad(this.File4, Server.MapPath("/UpLoad"));
samllpic[3] = "Upload/small/" + UpFileImg.MakeThumbnail(File4.PostedFile.FileName, Server.MapPath("/UpLoad//small"), 110, 80, "Cut");
// PhotoBLL.ADD(Convert.ToInt32(this.classid.Value), filePath[3]);
count++;
}
if (!string.IsNullOrEmpty(this.File5.Value))
{
filePath[4] = "Upload/" + UpFileImg.UpLoad(this.File5, Server.MapPath("/UpLoad"));
samllpic[4] = "Upload/small/" + UpFileImg.MakeThumbnail(File5.PostedFile.FileName, Server.MapPath("/UpLoad//small"), 110, 80, "Cut");
// PhotoBLL.ADD(Convert.ToInt32(this.classid.Value), filePath[4]);
count++;
}
if (count == 0)
{
Page.ClientScript.RegisterStartupScript(this.GetType(), "msg", "alert('至少选择一张图片!')", true);
return;
}
ColoProPicModel p = null;
for (int i = 0; i < filePath.Length; i++)
{
if (!string.IsNullOrEmpty(filePath[i]))
{
p = new ColoProPicModel();
p.F_Pic = filePath[i].ToString();
p.ColorID = 0;
p.ProID = int.Parse(Request.Form["id"]);//Convert.ToInt32(this.pid.Value);这块提示有错误:
确保方法参数的正确,将一个字符串转化为datetime时,先分析该字符串以获取日期,然后将每个变量放到datetime对象中
p.F_SmallPic =samllpic[i].ToStri
922c
ng();
ColoProPicBLL.AddProPic(p);
}
}
ProPicBind(Convert.ToInt32(this.pid.Value), 0);
}
}
}
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Colo.BLL;
using Colo.Entity;
using Web.PageBase.Utility;
using Colo.Web.code;
using System.Text;
namespace Colo.Web.admin.Products
{
public partial class ProPicAdmin : AdminPage
{
public string colorhtml = string.Empty;
protected void Page_Load(object sender, EventArgs e)
{
if (this.IsHttpPost)
{
if (!string.IsNullOrEmpty(Request.Form["id"]))
{
UpFileImg.DeleteImg(Request.Form["imgurl"].ToString());
ColoProPicBLL.DeleteProPicByID(Convert.ToInt32(Request.Form["id"]));
Page.ClientScript.RegisterStartupScript(this.GetType(), "m", "alert('删除成功');location.href='propicadmin.aspx?id=" + this.pid.Value + "'", true);
}
if (!string.IsNullOrEmpty(Request.Form["op"]))
{
if (Request.Form["op"].ToString() == "1")//设置产品封面
{
int proid = Convert.ToInt32(Request.Form["proid"]);
int picid = Convert.ToInt32(Request.Form["picid"]);
ColoProPicBLL.SetTopPic(proid, picid);
Page.ClientScript.RegisterStartupScript(this.GetType(), "m", "alert('产品封面设置成功!');location.href='propicadmin.aspx?id=" + this.pid.Value + "'", true);
}
}
}
else
{
if (!string.IsNullOrEmpty(Request.QueryString["id"]))
{
int id = Convert.ToInt32(Request.QueryString["id"]);
ProPicBind(id, 0);
// ProColorBind(id);
}
}
}
protected void ProPicBind(int id, int colorid)
{
ColoProModel p = ColoProBLL.GetProByID(id);
this.txtProName.Text = p.F_ProName;
this.pid.Value = id.ToString();
List<ColoProPicModel> list = ColoProPicBLL.GetProPicList(id, colorid);
PhotoList.DataSource = list;
PhotoList.DataBind();
}
protected void btnUpload_Click(object sender, EventArgs e)
{
string[] filePath = new string[5];
string[] samllpic = new string[5];
int count = 0;
if (!string.IsNullOrEmpty(this.File1.Value))
{
filePath[0] = "Upload/" + UpFileImg.UpLoad(this.File1, Server.MapPath("/UpLoad"));
samllpic[0] = "Upload/small/" + UpFileImg.MakeThumbnail(File1.PostedFile.FileName, Server.MapPath("/UpLoad//small"), 110, 80, "Cut");
// PhotoBLL.ADD(Convert.ToInt32(this.classid.Value), filePath[0]);
count++;
}
if (!string.IsNullOrEmpty(this.File2.Value))
{
filePath[1] = "Upload/" + UpFileImg.UpLoad(this.File2, Server.MapPath("/UpLoad"));
samllpic[1] = "Upload/small/" + UpFileImg.MakeThumbnail(File2.PostedFile.FileName, Server.MapPath("/UpLoad//small"), 110, 80, "Cut");
// PhotoBLL.ADD(Convert.ToInt32(this.classid.Value), filePath[1]);
count++;
}
if (!string.IsNullOrEmpty(this.File3.Value))
{
filePath[2] = "Upload/" + UpFileImg.UpLoad(this.File3, Server.MapPath("/UpLoad"));
samllpic[2] = "Upload/small/" + UpFileImg.MakeThumbnail(File3.PostedFile.FileName, Server.MapPath("/UpLoad//small"), 110, 80, "Cut");
// PhotoBLL.ADD(Convert.ToInt32(this.classid.Value), filePath[2]);
count++;
}
if (!string.IsNullOrEmpty(this.File4.Value))
{
filePath[3] = "Upload/" + UpFileImg.UpLoad(this.File4, Server.MapPath("/UpLoad"));
samllpic[3] = "Upload/small/" + UpFileImg.MakeThumbnail(File4.PostedFile.FileName, Server.MapPath("/UpLoad//small"), 110, 80, "Cut");
// PhotoBLL.ADD(Convert.ToInt32(this.classid.Value), filePath[3]);
count++;
}
if (!string.IsNullOrEmpty(this.File5.Value))
{
filePath[4] = "Upload/" + UpFileImg.UpLoad(this.File5, Server.MapPath("/UpLoad"));
samllpic[4] = "Upload/small/" + UpFileImg.MakeThumbnail(File5.PostedFile.FileName, Server.MapPath("/UpLoad//small"), 110, 80, "Cut");
// PhotoBLL.ADD(Convert.ToInt32(this.classid.Value), filePath[4]);
count++;
}
if (count == 0)
{
Page.ClientScript.RegisterStartupScript(this.GetType(), "msg", "alert('至少选择一张图片!')", true);
return;
}
ColoProPicModel p = null;
for (int i = 0; i < filePath.Length; i++)
{
if (!string.IsNullOrEmpty(filePath[i]))
{
p = new ColoProPicModel();
p.F_Pic = filePath[i].ToString();
p.ColorID = 0;
p.ProID = int.Parse(Request.Form["id"]);//Convert.ToInt32(this.pid.Value);这块提示有错误:
确保方法参数的正确,将一个字符串转化为datetime时,先分析该字符串以获取日期,然后将每个变量放到datetime对象中
p.F_SmallPic =samllpic[i].ToStri
922c
ng();
ColoProPicBLL.AddProPic(p);
}
}
ProPicBind(Convert.ToInt32(this.pid.Value), 0);
}
}
}
相关文章推荐
- 构建网站图片上传不上去
- 构建网站图片上传不上去
- 构建网站图片上传不上去
- 构建网站图片上传不上去
- 构建网站图片上传不上去
- Java实现给网站上传图片盖章的方法
- .net网站上传图片换电脑不显示 当不用网站的IP地址访问图片,只用相对路径访问时,在发布网站的时候,将上传图片的目标文件夹,包含在项目中再发布即可。
- 使用vue构建一个上传图片表单
- 夺命雷公狗ThinkPHP项目之----企业网站5之栏目的添加(主要是图片上传)
- Go语言练习:网络编程实例——简易图片上传网站
- 图片服务器上图片的管理网站上传与前台显示
- 解决网站中上传的图片在IE中不显示 chrome firefox下却正常
- PHP使用之网站后台上传图片出错,提示Warning: mkdir() [function.mkdir]: Permission denied……
- 在线修改图片尺寸缩放网站(完美解决图片过大无法上传问题)
- 关于asp.net网站上传图片功能失败的处理
- asp网站后台上传图片出错 提示未定义类
- 5个常用的上传图片进行搜索的网站
- IIS发布网站部分特殊配置--图片上传至别的服务器、iis配置 通配符应用程序映、iis配置 C#底层拦截.htm文件请求
- 织梦Dedecms网站后台无法上传图片的步骤详解
- [网站公告]又拍云API故障造成图片无法上传