我现在需要用一个字段 定义图片的编号,但是需要粗村多张图片,名称还自动根据编号定义的。
我就是想知道怎么自动的为一个编号的多张图片设置图片名称,
例如:编号a 图片a1.jpg,a2.jpg,a3.jpg。
考虑到重新登录再次添加 怎么办?

解决方案 »

  1.   

    假设用户关联图片那么存在的表  
    User
    UserId UserName ...Picture
    PicId  PicName UserID保存的时候,先得到当前用户的Id,然后根据Id自动生成图片名称,插入
      

  2.   

    把编号存储起来,例如放到数据库中,然后根据那个maxid,再往后加。
      

  3.   

    谢谢各位了。我用了一个超级笨的方法做出来了。新加了一个列用来存储添加图片的数量,添加了就取出图片的路径在加上新加图片的路径,然后再存进去。
     int sum;
            string Photo = "";
            string fpName = this.up1.PostedFile.FileName.ToString();
            string pName = fpName.Substring(fpName.LastIndexOf("\\") + 1);
            string pType = pName.Substring(pName.LastIndexOf(".") + 1);
          
         
           if (pType == "jpg" || pType == "png" || pType == "gif" || pType == "jpeg" || pType == "JPG" || pType == "PNG" || pType == "GIF" || pType == "JPEG")
            {
                string a = "select ppsum from pondPhoto where ppNumber='"+Label1.Text+"'";
                
                sum= dbuse.ReInt(a);
                if (sum > 0)//判断图片添加的数量
                {
                    sum = sum + 1;
                    string b = "select ppPhoto from pondPhoto where ppNumber='" + Label1.Text + "'";
                    Photo = dbuse.ReStr(b);
                    Photo = Photo + "/" + this.Label1.Text + sum+"."+pType;
                    string str="update pondPhoto set ppsum="+sum+",ppPhoto='"+Photo+"' where ppNumber='"+this.Label1.Text+"'";
                    dbuse.ReVoid(str);
                }
              else 
                {
                    string Photos =this.Label1.Text+1+"."+pType;
                    sum = 1;
                  string   Time = DateTime.Now.ToShortDateString();
                    string str = "insert into pondPhoto values('"+this.Label1.Text +"','"+Photos +"',"+sum+",'"+Time+"')";
                    dbuse.ReVoid(str);
                }
               
               this.up1.PostedFile.SaveAs(Server.MapPath("~/UpFile") + "\\" + this.Label1.Text + sum+"." + pType);
                Response.Write("<script>alert('上传成功!');</script>");
            }
            else
            {
                Response.Write("<script>alert('格式不正确!');</script>");
            }求大家多指教点。我觉得格式判断不是很好。