1、上传文件,代码是没问题的,但是我在调用的时候出现了iframe跨域问题,(没有解决),在不牵扯主页面套用子页面的情况下使用是可以的。
代码:
#region 上传文件
[HttpPost]
public HttpResponseMessage UpLoadFile()
{
// 检查是否是 multipart/form-data
if (!Request.Content.IsMimeMultipartContent("form-data"))
{
throw new HttpResponseException(HttpStatusCode.UnsupportedMediaType);
}
string json;
string productName = HttpContext.Current.Request.Form["TempProductName"];
HttpPostedFile file = HttpContext.Current.Request.Files["TempLicense"];
if (file != null)
{
if (file.ContentLength / 1024 > 100)//不能超过100KB
{
json = "{\"success\":0,\"msg\&#