图片批量上传

Ying-zi 2010-10-07 06:55:37
我想要实现的效果为:点击“浏览”,可以选择多张图片,然后,再通过点击“上传”按钮再提交到数据库。就是 “批量上传”功能。请行家指点指点!
...全文
173 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
SK_Aqi 2010-10-07
  • 打赏
  • 举报
回复
简单来说,6楼的简单理解
怎么来这一出 2010-10-07
  • 打赏
  • 举报
回复
protected void Button1_Click(object sender, EventArgs e)
{
try
{

fileup(FileUpload6, TextBox1);
fileup(FileUpload5, TextBox2);
fileup(FileUpload4, TextBox3);
fileup(FileUpload3, TextBox4);
fileup(FileUpload2, TextBox5);


}
catch (Exception ex)
{
throw ex;
}
}
public bool fileup(FileUpload f,TextBox tex)
{
Boolean bo = false;
string magazine_id = DropDownList1.SelectedItem.Value;
string image_remark = tex.Text;
string time = System.DateTime.Now.ToString();
if (f.HasFile)
{
String name = f.PostedFile.FileName;
FileInfo file = new FileInfo(name);
//string fileName = file.Name;
string fileName = DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString() + DateTime.Now.Day.ToString() + DateTime.Now.Hour.ToString() + DateTime.Now.Minute.ToString() + DateTime.Now.Second.ToString() + file.Name; ;

string webFilepath = Server.MapPath("userfiles/IMAGE/myphoto/" + magazine_id + fileName);
string fileContentType = f.PostedFile.ContentType;

if (fileContentType == "image/gif" || fileContentType == "image/pjpeg" || fileContentType == "image/jpg")
{
if (!File.Exists(webFilepath))
{
try
{

f.SaveAs(webFilepath);

this.AddImageWatermark(webFilepath);

string url = "~/userfiles/IMAGE/myphoto/" + magazine_id + fileName;

string sql2 = "insert into image(image_url,image_remark,magazine_id)values('" + url + "','" + image_remark + "','" + magazine_id + "')";
Datacommand.datacom().exqut(sql2);
Response.Write("<script language = javascript>alert('提交成功!');</script>");



bo = true;


}
catch (Exception ex)
{
Label9.Visible = true;
Label9.Text = "图片上传失败,失败原因:" + ex.Message;
}
}
else
{
Label9.Visible = true;
Label9.Text = "图片已存在,请重命名后上传";

}
}
else
{
Label9.Visible = true;
Label9.Text = "为节省服务器空间,提高网站速度,请上传*.jpg、*.gif、*pjpeg类型图片";
}


}
return bo;
}
hchxxzx 2010-10-07
  • 打赏
  • 举报
回复
直接使用flash上传组件上传.
swfupload
http://www.swfupload.org/
zhubo_1117 2010-10-07
  • 打赏
  • 举报
回复
Jquery MultiUpload
天下如山 2010-10-07
  • 打赏
  • 举报
回复
搜搜 一批的例子 然后改改。
teerhu 2010-10-07
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 wuyq11 的回复:]
function AddFile()
{
var strFile="<input name=\"upload_A\" type='file' class='inputText' style='WIDTH:350px;'/><br/>";
document.getElementById("td_uploadFile").insertAdjacentHTML("beforeEnd",strFil……
[/Quote]

up
wuyq11 2010-10-07
  • 打赏
  • 举报
回复
function AddFile()
{
var strFile="<input name=\"upload_A\" type='file' class='inputText' style='WIDTH:350px;'/><br/>";
document.getElementById("td_uploadFile").insertAdjacentHTML("beforeEnd",strFile);
}
<td id="td_uploadFile" align="center">
<input id="upload_A" name="upload_A" type="file" class="inputText"
style="width: 350px; display:none;" runat="server" />
</td>

HttpFileCollection Files = HttpContext.Current.Request.Files;
for (int i = 0; i < Files.Count; i++)
{
}
http://topic.csdn.net/u/20100807/11/4801f6d9-4fd0-4b87-84b4-f28f9ae474d7.html

62,272

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧