本帖最后由 葉公 于 2017-4-20 22:56 编辑
今日做了个文件上传,当文件大小超过20M,就会报错,说什么跨域。求助下~~页面:
<f:Toolbar runat="server">
<Items>
<f:FileUpload ID="txtVideo" runat="server" ButtonIcon="DiskUpload" AutoPostBack="true"></f:FileUpload>
<f:HiddenField runat="server" ID="lblVideo" ></f:HiddenField>
</Items>
</f:Toolbar>
<f:Image runat="server" ID ="Image1" Width="100" Height="40" Hidden="true"></f:Image>
cs代码:
protected void txtVideo_FileSelected(object sender, EventArgs e)
{
List<string> fileType = new List<string> { "flv", "mp4", "avi"};
string fileSuffix = Path.GetExtension(txtVideo.PostedFile.FileName);
if (txtVideo.HasFile)
{
string fileName = txtVideo.ShortFileName;
if (!ValidateFileType(fileName, fileType))
{
Alert.Show("无效的文件类型!");
return;
}
string url = @"uploads/video/" + pictureName() + fileSuffix;
lblVideo.Text = url;
txtVideo.SaveAs(Server.MapPath("~/" + url));
}
}
webconfig
<!-- 请求正文的最大值: 512000K = 500M -->
<httpRuntime maxRequestLength="512000" requestValidationMode="2.0" />
<customErrors mode="Off">
报错:
{success:false,message:"Blocked a frame with origin "http://localhost:56172" from accessing a cross-origin frame."}
或者
{success:false,message:"没有权限"}
|