日期:2014-05-17 浏览次数:20569 次
#region 上传文件
/// <summary>
/// 上传文件
/// </summary>
/// <returns></returns>
private ArrayList SaveFiles()
{
ArrayList fileArray = new ArrayList();
///'遍历File表单元素
HttpFileCollection files = HttpContext.Current.Request.Files;
try
{
for (int iFile = 0; iFile < files.Count; iFile++)
{
///'检查文件扩展名字
HttpPostedFile postedFile = files[iFile];
string fileName, fileExtension;
fileName = System.IO.Path.GetFileName(postedFile.FileName);
if (fileName != "")
{
fileExtension = System.IO.Path.GetExtension(fileName);
fileName = DateTime.Now.ToString("yyyyMMddHHmmss") + iFile.ToString() + fileExtension;
///'可根据扩展名字的不同保存到不同的文件夹
///注意:可能要修改你的文件夹的匿名写入权限。
postedFile.SaveAs(System.Web.HttpContext.Current.Request.MapPath("file/") + fileName);
fileArray.Add(System.Web.HttpContext.Current.Request.MapPath("file/") + fileName);
}
}
for (int i = fileArray.Count + 1; i <= 5; i++)
{
fileArray.Add("");
}
return fileArray;
}
catch
{
throw new Exception("BIG");
}
}
#endregion
------解决方案--------------------
mark 帮顶
------解决方案--------------------
考虑用单例
singleton
在web服务器端开一个线程,需要有一个链表,记录用户上传上来的图片路径,注意这里需要用到锁
这个线程主要是负责把用户上传的图片传到别web服务器上,这样在一个线程里的话就不需要考虑并发了
------解决方案--------------------
学习...up
------解决方案--------------------
...
------解决方案--------------------
学习` 关注` UP
------解决方案--------------------
学习了 ··
------解决方案--------------------
你的『同步』指什么?我看不出有什么性能问题,直接把数据传过去就是了。