Server.MapPath获取文件绝对路径

获取到的路径是网站的路径,而不是文件的路径。

顺便问一下,我用weblint上传文件,前端是<input type=file 如何将前端选定文件的绝对路径传道一般处理程序

            string title = context.Request.Form["title"];
            HttpPostedFile upFile = HttpContext.Current.Request.Files["upLoad"];

            //提供用于将数据发送到和接收来自通过 URI 确认的资源数据的常用方法
                WebClient client = new WebClient();

                       //分配10000000字节给mbyte
                byte[] mbyte = new byte[1000000];
                //数组长度
                int allmybyte = (int)mbyte.Length;
                int startmbyte = 0;
//上传文件地址
                string URLAddress =System.Web.HttpContext.Current.Server.MapPath("/"+upFile.FileName);
                //上传文件存放位置
                string receivePath = context.Server.MapPath("~/");
                //从上传地址创建一个可读流
                Stream str = client.OpenRead(URLAddress);
                //实例化以特定编码读取文件的读取器
                StreamReader reader = new StreamReader(str);


                while (allmybyte > 0)
                {
                    //m:读入缓冲区的总字节数
                    //从当前流的startmbyte位置,欲读取allmybyte字节,放入byte数组
                    int m = str.Read(mbyte, startmbyte, allmybyte);
                    if (m == 0)
                        break;
                    //读取起始位置加m
                    startmbyte += m;
                    //要读取的字节数减少m
                    allmybyte -= m;
                }
                //释放流读取器资源
                reader.Dispose();
                //释放流资源
                str.Dispose();
                //文件上传下来存放的路径
                string path = receivePath + System.IO.Path.GetFileName(URLAddress);
                //实例化文件操作类。设置文件的路径,打开方式,读写权限
                FileStream fstr = new FileStream(path, FileMode.OpenOrCreate, FileAccess.Write);
                //往文件流里写入字节
                fstr.Write(mbyte, 0, startmbyte);
                //清除此流的缓冲区,使得所有缓冲的数据都写入到文件中
                fstr.Flush();
                //关闭当前流并释放与之关联的所有资源
                fstr.Close(); 

http://blog.163.com/budong_weimin_zh/blog/static/129198524201061834217179/