如何使用 Uploadify 上传 mp4 and/or 允许在 IIS 中上传 mp4
How to upload mp4 with Uploadify and/or allow mp4 upload in IIS
我正在开发一个应用程序,我们一直在使用 Uploadify 上传 .wmv 和 .jpg。我添加了允许 .mp4 上传的功能,并且在本地上传时一切正常,但不能上传到服务器。在 IIS 中,我在每个适用的文件夹中为 .mp4 文件添加了 video/mp4 的 MIME 类型,并且可以 play 文件正常(手动添加时)......但对于某些因为我无法使用 Uploadify 上传 .mp4 文件到我的服务器。这是 jQuery / javascript 代码:
$('#fileInput').uploadify({
'uploader': 'uploadify/uploadify.swf',
'script': './Upload.ashx',
'cancelImg': 'uploadify/cancel.png',
'auto': false,
'multi': true,
'fileExt': '*.jpg;*.jpeg;*.wmv;*.mp4',
'fileDesc': 'Allowed Files (.JPG, .JPEG, .WMV, .MP4)',
'queueSizeLimit': 3,
'sizeLimit': 999999999,
'buttonText': 'Browse Files',
'onError': function(event, ID, fileObj, errorObj) {
alert(errorObj.type + ' Error: ' + errorObj.info);
},
'onComplete': function(event, ID, fileObj, response, data) {
fileNames += fileObj.name + ',';
},
'onAllComplete': function(event, data) {
if (data.errors == 0) {
$.ajax({
type: "POST",
data: $.toJSON({
Name: $("[id$='txt_Name']").val(),
FileNames: fileNames,
Active: $("[id$='rdo_ActiveYes']")[0].checked,
Department: $("[id$='ddl_Department']").val(),
Category: $("[id$='ddl_Category']").val(),
Description: $("[id$='txt_Description']").val()
//YouTubeURL: $("[id$='txt_YouTubeURL']").val()
}),
url: "WebMethods.aspx/InsertVideo",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function(results) {
document.location.href = "./AddVideo.aspx";
},
error: function(xhr, status, errorThrown) {
alert(xhr.responseText);
}
});
}
else {
alert('There was an error uploading the files; process will be aborted');
}
}
});
我在添加MIME类型后重启了IIS(6.0),确保文件大小不会太大。我仍然可以上传 .jpg 和 .wmv 文件。我是否需要在 IIS 的任何位置允许 'upload file type'?还是我还缺少其他东西?如果需要任何其他信息,请告诉我。
编辑:我从 Uploadify 得到的错误是 "HTTP Error: 500"
迪布斯,
我会检查目标服务器上文件的写入权限。例如,如果您试图覆盖 "readonly" 的现有文件,它可能会给您一个错误。
我正在开发一个应用程序,我们一直在使用 Uploadify 上传 .wmv 和 .jpg。我添加了允许 .mp4 上传的功能,并且在本地上传时一切正常,但不能上传到服务器。在 IIS 中,我在每个适用的文件夹中为 .mp4 文件添加了 video/mp4 的 MIME 类型,并且可以 play 文件正常(手动添加时)......但对于某些因为我无法使用 Uploadify 上传 .mp4 文件到我的服务器。这是 jQuery / javascript 代码:
$('#fileInput').uploadify({
'uploader': 'uploadify/uploadify.swf',
'script': './Upload.ashx',
'cancelImg': 'uploadify/cancel.png',
'auto': false,
'multi': true,
'fileExt': '*.jpg;*.jpeg;*.wmv;*.mp4',
'fileDesc': 'Allowed Files (.JPG, .JPEG, .WMV, .MP4)',
'queueSizeLimit': 3,
'sizeLimit': 999999999,
'buttonText': 'Browse Files',
'onError': function(event, ID, fileObj, errorObj) {
alert(errorObj.type + ' Error: ' + errorObj.info);
},
'onComplete': function(event, ID, fileObj, response, data) {
fileNames += fileObj.name + ',';
},
'onAllComplete': function(event, data) {
if (data.errors == 0) {
$.ajax({
type: "POST",
data: $.toJSON({
Name: $("[id$='txt_Name']").val(),
FileNames: fileNames,
Active: $("[id$='rdo_ActiveYes']")[0].checked,
Department: $("[id$='ddl_Department']").val(),
Category: $("[id$='ddl_Category']").val(),
Description: $("[id$='txt_Description']").val()
//YouTubeURL: $("[id$='txt_YouTubeURL']").val()
}),
url: "WebMethods.aspx/InsertVideo",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function(results) {
document.location.href = "./AddVideo.aspx";
},
error: function(xhr, status, errorThrown) {
alert(xhr.responseText);
}
});
}
else {
alert('There was an error uploading the files; process will be aborted');
}
}
});
我在添加MIME类型后重启了IIS(6.0),确保文件大小不会太大。我仍然可以上传 .jpg 和 .wmv 文件。我是否需要在 IIS 的任何位置允许 'upload file type'?还是我还缺少其他东西?如果需要任何其他信息,请告诉我。
编辑:我从 Uploadify 得到的错误是 "HTTP Error: 500"
迪布斯,
我会检查目标服务器上文件的写入权限。例如,如果您试图覆盖 "readonly" 的现有文件,它可能会给您一个错误。