如何使用J查询在Web方法中访问上载的文件 [英] How can I access the uploaded file in web method using J query
本文介绍了如何使用J查询在Web方法中访问上载的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在Web方法中访问文件对象但它返回空值
我尝试过:
I Am Accessing The File Object In Web Method But Its Return Null Value
What I have tried:
function SaveTempFilesOnServer() {
debugger;
// ------------------ Upload the file ------------------
debugger;
var uploadControl = document.getElementById('');
var obj={};
obj.context = uploadControl.target.files[0];
alert(obj.context);
$.ajax({
async: false,
type: "POST",
url: "PanUpdate_New.aspx/SaveTempFilesOnServer",
data: JSON.stringify(obj),
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function(data) {
debugger;
alert("1");
},
error: function() {
alert("Failed to load Data...!!!");
}
});
}
[WebMethod(EnableSession = true)]
public static List<file> SaveTempFilesOnServer(object context)
{
List<file> ListFile = new List<file>();
return ListFile ;
}
推荐答案
.ajax({
async: false ,
类型: POST,
url:< span class =code-string> PanUpdate_New.aspx / SaveTempFilesOnServer,
data: JSON .stringify(obj),
contentType: application / json; charset = utf -8,
dataType: json,
成功:功能(数据){
调试器;
alert ( 1);
},
错误: function (){
alert( 无法加载数据...... !!!);
}
});
}
[WebMethod(EnableSession = true )]
public static 列表< file> SaveTempFilesOnServer(对象上下文)
{
List< file> ListFile = new List< file>();
return ListFile;
}
.ajax({ async: false, type: "POST", url: "PanUpdate_New.aspx/SaveTempFilesOnServer", data: JSON.stringify(obj), contentType: "application/json; charset=utf-8", dataType: "json", success: function(data) { debugger; alert("1"); }, error: function() { alert("Failed to load Data...!!!"); } }); } [WebMethod(EnableSession = true)] public static List<file> SaveTempFilesOnServer(object context) { List<file> ListFile = new List<file>(); return ListFile ; }
查看这篇文章
JQuery-在asp.net WebMethod c#中使用ajax和jquery异步文件上传[ ^ ]
check this article
JQuery - Asynchronous file upload using ajax and jquery in asp.net WebMethod c# [^]
这篇关于如何使用J查询在Web方法中访问上载的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文