嘿,我的项目目录是这样的:
project
codes
fileupload(ashx)
scripts
image
web-pages
home(aspx)
about(aspx)
FileUpload(aspx)
我在我的 FileUpload(aspx) 中使用这个 ajax 函数:
<script>
function ajaxFileUpload() {
$.ajaxFileUpload({
url: "/FileUpload.ashx", // The problem is here
secureuri: false,
fileElementId: 'fileToUpload',
dataType: 'json',
success: function (data, status) {
if (typeof (data.error) != 'undefined') {
if (data.error != '') {
alert(data.error);
} else {
ShowUploadedFiles(data.upfile, filename);
$('#fileToUpload').val("");
}
}
},
error: function (data, status, e) {
alert(e);
}
});
}
</script>
如何从此函数调用我的处理程序(fileupload.ashx):我尝试了很多方法:
1 - url: "../codes/FileUpload.ashx", Not working
2 - url: "~/codes/FileUpload.ashx", Not working
3 - url: "./codes/FileUpload.ashx", Not working
4 - url: "/codes/FileUpload.ashx", Not working
5 - url: "/project/codes/FileUpload.ashx", not working
6 - url: "codes/FileUpload.ashx", not working
7 - url: "/FileUpload.ashx", not working
PS:当我更改 FileUpload.aspx 的目录并将其放在项目的主文件夹中时...它将与此 url 完美配合:codes/FileUpload.ashx
那么有什么想法吗?