using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web;
using System.Web.Http;

namespace WebApi.Controllers
{
    public class UploadController : ApiController
    {

        public void Up()
        {
            //多图上传
            HttpContext context = HttpContext.Current;
            HttpFileCollection files = context.Request.Files;
            string path = context.Request.MapPath("~/");
            string strPath = path + "App_Data/";
            for (int i = 0; i < files.Count; i++)
            {
                strPath += files[i].FileName;
                files[i].SaveAs(strPath);
            }
            context.Response.Clear();
            context.Response.Write(strPath);
            context.Response.End();
        }
    }
}

 

posted on 2017-03-20 08:53  被遗忘的优雅  阅读(1177)  评论(0编辑  收藏  举报