private void save() { if (ViewState["UploadedCount"] == null) ViewState["UploadedCount"] = 0; int iCount = Convert.ToInt32(ViewState["UploadedCount"]); if (iCount < 5 ) { //do upload and set Session ViewState["UploadedCount"] = iCount + 1; } else if (iCount == 5) { //call full(); //disable up button //save the data to database } }
你想保存什么在Session里面? ArrayList alUploadedFiles = new ArrayList(); Session["alUploadedFiles"] = alUploadedFiles; when save: alUploadedFiles = (ArrayList)Session["alUploadedFiles"]; int i = alUploadedFiles.Count; i++; alUploadedFiles[i] = filename; //the information that you want to save Session["alUploadedFiles"] = alUploadedFiles;
When you save data fron session to database, you can use for to get all data; alUploadedFiles = (ArrayList)Session["alUploadedFiles"]; for(int i=0; i < alUploadedFiles.Count;i++) { string filename = alUploadedFiles[i].ToString(); //do save to database }
Maybe the better use ArrayList.Add(obejct value) to add a new value: Like: alUploadedFiles.Add(path); //path is the image's path这要看你怎么决定用户不再上传了;比如有一个按钮“保存”,当用户点击后就保存到数据库,这时候不管用户上载了几张都是可以的
http://www.stqq.net/01.jpg
http://www.stqq.net/02jpg
http://www.stqq.net/03.jpg高手注意看3个图的变化,当传到5张完时, 上传的按钮消失了(c#)可用up.Enabled=False;实现要求是C#代码~~~~~~~~~~~~~~特别注意: 一定要用一个 input 来上传文件 不要多个input框。
{
if (ViewState["UploadedCount"] == null) ViewState["UploadedCount"] = 0; int iCount = Convert.ToInt32(ViewState["UploadedCount"]);
if (iCount < 5 )
{
//do upload and set Session
ViewState["UploadedCount"] = iCount + 1;
}
else if (iCount == 5)
{
//call full();
//disable up button
//save the data to database
}
}
你的思路不错呀,我试试,等... 还有session的值怎么取呢?5次得到的值都不同呀,
就是我想用数组来存放5次的值,放在同一个 session["xxx"]里,不知能否实现?如不行,用5个session也可以。
ArrayList alUploadedFiles = new ArrayList();
Session["alUploadedFiles"] = alUploadedFiles;
when save:
alUploadedFiles = (ArrayList)Session["alUploadedFiles"];
int i = alUploadedFiles.Count;
i++;
alUploadedFiles[i] = filename; //the information that you want to save
Session["alUploadedFiles"] = alUploadedFiles;
alUploadedFiles = (ArrayList)Session["alUploadedFiles"];
for(int i=0; i < alUploadedFiles.Count;i++)
{
string filename = alUploadedFiles[i].ToString();
//do save to database
}
Like: alUploadedFiles.Add(path); //path is the image's path这要看你怎么决定用户不再上传了;比如有一个按钮“保存”,当用户点击后就保存到数据库,这时候不管用户上载了几张都是可以的
我想把图片保存在Session里~ 有几张则 保存几个Session,然后等 [发表] 时再执行提取Session图片,并另存在指定的目录下,同时记录图片的url 在数据库里?