protected string upload(object img)
{
string[] imgList = img.ToString().Split(new char[]{','}, StringSplitOptions.RemoveEmptyEntries);
foreach (var item in imgList)
{
HttpPostedFile postedFile;
postedFile.SaveAs(Server.MapPath("temp") + "\\" + item);
}
return "true";
}img是前台传过来的多文件
imgList里存储的是文件名数组
怎么使用PostFile上传?
解决方案 »
- 一个框架里的treeview 如何给另一框架的url加参数
- 使用detailsview的时候表单很长,能不能让他分成两列显示?
- 如何在javascript中使用随机函数生产字符串或者数字?
- sql2000的存储过程参数最多能返回多长的数据?能返回varchar(8000)个不?
- 作了一个用Js遍历2.0TreeView节点的函数,后来发现一个问题!
- 在线等,问题解决马上给分~~~
- aspnetdb数据库难题,思归,孟子老师请进~
- VS2008调试时怎么自动定在报错的地方
- TextBox如何触发失去焦点事件?
- 控件高手帮个忙!
- .net程序中 “/”应用程序中的服务器错误。怎么解决???
- 发送邮件时用户名如何绑定汉字 急。。
postedFile.SaveAs(Server.MapPath("temp") + "\\" + item);
你这段代码会出现未将对象应用到实例。SaveAs不是静态方法。
String TempFileName;
HttpFileCollection MyFileCollection = imgList;
for (int Loop1 = 0; Loop1 < MyFileCollection.Count; Loop1++)
{
TempFileName = Server.MapPath("temp") + "\\"+ Loop1.ToString();
MyFileCollection[Loop1].SaveAs(TempFileName);
}
return "true";
跟这没关系吧
HttpPostedFile postedFile;这样写报的是为实例化的错