当前位置: 代码迷 >> ASP.NET >> 用户上传图片到 web服务器 要同步到 图片服务器,征求一些方法,多谢
  详细解决方案

用户上传图片到 web服务器 要同步到 图片服务器,征求一些方法,多谢

热度:9007   发布时间:2013-02-25 00:00:00.0
用户上传图片到 web服务器 要同步到 图片服务器,征求一些方法,谢谢!
如题,要考虑到性能问题。

------解决方案--------------------------------------------------------
C# code
 #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
------解决方案--------------------------------------------------------
学习了 ··
------解决方案--------------------------------------------------------
你的『同步』指什么?我看不出有什么性能问题,直接把数据传过去就是了。
  相关解决方案