我使用 dropzone js 将多个图像上传到服务器并使用linq将每个图像路径保存在数据库中,因此我尝试使用图像路径填充列表,然后访问列表以保存linq列表中的路径,但列表不会填充
有人知道问题是什么吗?
public partial class additemdetails : System.Web.UI.Page
{
DataClassesDataContext db = new DataClassesDataContext();
List<string> img = new List<string>();
item itm = new item();
protected void Page_Load(object sender, EventArgs e)
{
List<string> img = new List<string>();
foreach (string s in Request.Files)
{
HttpPostedFile file = Request.Files[s];
int fileSizeInBytes = file.ContentLength;
string fileName = file.FileName;// Request.Headers["X-File-Name"];
string fileExtension = "";
fileExtension = Path.GetExtension(fileName);
string savedFileName = Guid.NewGuid().ToString() + fileExtension;
string path = HttpContext.Current.Server.MapPath("~/img/items/");
string filename = path + savedFileName;
img.Add(filename);
itm.img1 = img[0];
file.SaveAs(filename);
}
}
}