ASPupload 'if Not File Is Nothing' 始终 returns 错误
ASPupload 'if Not File Is Nothing' always returns false
使用Persits ASPupload component上传和处理文件(经典ASP)。
正在通过 jQuery ajax 表单上传文件。
我 运行 遇到了一个奇怪的情况,习惯测试 if Not File Is Nothing Then
总是 returns false
即使文件已经上传(我可以看到它在服务器上)。
这是我的 jQuery 代码:
var hiddenSignature = $("#hiddenSignature").val();
var formData = new FormData();
formData.append('closingPic', $('#closingPic')[0].files[0]);
formData.append('hiddenSignature',hiddenSignature);
$.ajax({
url: "ajax_tickets_file.asp?action=cost",
type: "POST",
enctype: 'multipart/form-data',
contentType: false,
processData: false,
data: formData,
beforeSend: function() {
...
},
success: function(msg) {
...
}
});
这是 ajax_tickets_file.asp 上的服务器端代码:
Set objUpload = Server.CreateObject("Persits.Upload.1")
With objUpload
.CodePage = 65001
.OverwriteFiles = False
Set file = .Files("closingPic")
.SaveVirtual defaultUploadsFolder // a file is indeed saved on the server, at the correct location
response.write " saved "
if Not file Is Nothing Then
response.write “we have a file”
else
response.write "no file" // this is what I get
end if
因此,如前所述,我打印了“无文件”。
怎么会这样?
谢谢
H/T 感谢 Persits ASPupload 的所有者帮助我
代码应该是:
.CodePage = 65001
.OverwriteFiles = False
//these 2 lines should be in reversed order: 'save' before 'set file'
.SaveVirtual defaultUploadsFolder
Set file = .Files("closingPic")
使用Persits ASPupload component上传和处理文件(经典ASP)。
正在通过 jQuery ajax 表单上传文件。
我 运行 遇到了一个奇怪的情况,习惯测试 if Not File Is Nothing Then
总是 returns false
即使文件已经上传(我可以看到它在服务器上)。
这是我的 jQuery 代码:
var hiddenSignature = $("#hiddenSignature").val();
var formData = new FormData();
formData.append('closingPic', $('#closingPic')[0].files[0]);
formData.append('hiddenSignature',hiddenSignature);
$.ajax({
url: "ajax_tickets_file.asp?action=cost",
type: "POST",
enctype: 'multipart/form-data',
contentType: false,
processData: false,
data: formData,
beforeSend: function() {
...
},
success: function(msg) {
...
}
});
这是 ajax_tickets_file.asp 上的服务器端代码:
Set objUpload = Server.CreateObject("Persits.Upload.1")
With objUpload
.CodePage = 65001
.OverwriteFiles = False
Set file = .Files("closingPic")
.SaveVirtual defaultUploadsFolder // a file is indeed saved on the server, at the correct location
response.write " saved "
if Not file Is Nothing Then
response.write “we have a file”
else
response.write "no file" // this is what I get
end if
因此,如前所述,我打印了“无文件”。
怎么会这样?
谢谢
H/T 感谢 Persits ASPupload 的所有者帮助我
代码应该是:
.CodePage = 65001
.OverwriteFiles = False
//these 2 lines should be in reversed order: 'save' before 'set file'
.SaveVirtual defaultUploadsFolder
Set file = .Files("closingPic")