有哪位仁兄实现过类似于163邮箱那样的添加附件功能啊,就是选择完文件后就能直接上传

解决方案 »

  1.   

     System.IO.File.Copy(FileName, phyPath, true);FileName//你的文件路径
    phyPath //你要复制到服务器的路径.或者你就用FileUpload控件
      

  2.   

    动态添加rows,模仿网易邮箱添加附件功能.<script language=javascript> 
                 
        function AddRow() 
        {     
            var newRow = document.getElementById("row").cloneNode(true);                 
           table1.appendChild(newRow);                 
        } 
    </script>http://www.cnblogs.com/tangdebing/archive/2008/01/08/728954.html
      

  3.   

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.IO;namespace SqlBLL
    {
        public class FileUp
        {
            /// <summary>
            /// 传递上传控件,实习上传程序
            /// </summary>
            /// <param name="fiu">上传控件</param>
            /// <param name="filePath">文件名虚拟路径对应的物理路径
            /// eg:
            /// Server.MapPath("~/filepath")</param>
            /// <param name="errmsg">输出参数 错误信息发生错误返回null</param>
            /// <returns></returns>
            public static string GetFileUp(System.Web.UI.WebControls.FileUpload fiu, string filePath, out string errmsg)
            {
                string imageName = null;
                if (fiu.HasFile)
                {
                    bool fileIsTrue = false;
                    string fileExpand = Path.GetExtension(fiu.FileName).ToLower().Trim();
                    //定义扩展名的格式
                    string[] ExpandName = { ".gif", ".jpg", ".bmp", ".png" };
                    for (int i = 0; i < ExpandName.Length; i++)
                    {
                        if (ExpandName[i] == fileExpand)
                            fileIsTrue = true;
                    }
                    if (fileIsTrue)
                    {
                        //判断路径是否存在
                        if (!Directory.Exists(filePath))
                        {
                            Directory.CreateDirectory(filePath);
                        }
                        imageName = photoName() + fileExpand;
                        fiu.SaveAs(filePath +imageName);
                    }
                    else
                    {
                        errmsg = "只能上传图片格式的文件";
                        return null;
                    }
                }
                else
                {
                    errmsg = "文件不存在";
                    return null;
                }
                errmsg = "";
                return imageName;
            }        /// <summary>
            /// 生成随机名称
            /// </summary>
            /// <returns></returns>
            public static string photoName()
            {
                string datetime = Convert.ToString(DateTime.Now);
                //文件名
                string filename = null;
                for (int i = 0; i < datetime.Length; i++)
                {
                    if (datetime[i] >= '0' && datetime[i] <= '9')
                        filename += datetime[i];
                }
                return filename;
            }
        }
    }
      

  4.   

    就可以用upload控件,可以实现,