VB.net文件上传使用的AjaxCall [英] VB.net FileUpload using Ajaxcall
问题描述
您好我有一个jqGrid的亚格。这里面我已经上传的控制。
上传控制罚款高达工作要求的文件,并选择该文件。
但我无法读取后端vb.net侧文件的价值。
Javascript的code:
$('#FormPath')[0] .files [0]
返回 [对象,文件]。
< BR>
这意味着它是能够读取文件。</ P>
变种FD =新FORMDATA();
fd.append('文件',$('#FormPath')[0] .files [0]);
$阿贾克斯({
网址:Forms.aspx / UploadFormDetails',
数据:FD,
缓存:假的,
过程数据:假的,
的contentType:假的,
键入:POST,
成功:函数(FD){
警报(FD);
}
});
我的运气不好是不打下面提到的code。如果它击中我可以读取该文件。 Vb.net code
&LT;的WebMethod&GT; _
公共共享功能UploadFormDetails()作为字符串
昏暗httpPostedFile = HttpContext.Current.Request.Files(UploadedFile的)
如果httpPostedFile状态并没有任何然后
得到完整的文件路径
昏暗fileSavePath = Path.Combine(HttpContext.Current.Server.MapPath(/附件/ PDF /表格/),httpPostedFile.FileName)
保存上传的文件,以UPLOADEDFILES文件夹
httpPostedFile.SaveAs(fileSavePath)
结束如果
返回
结束功能
任何的身体有什么想法
最后我做到这一点通过处理程序文件。我想在很多方面。但是,这是唯一的选择制定出适合我。
Hi i have a Jqgrid subgrid. inside that i have upload control.
upload control working fine upto asking for the file and select the file.
But i am unable to read the file value in the back end vb.net side.
Javascript code :
$('#FormPath')[0].files[0]
will return [object,file].
That means it is able to read the file.
var fd = new FormData();
fd.append('file', $('#FormPath')[0].files[0]);
$.ajax({
url: 'Forms.aspx/UploadFormDetails',
data: fd,
cache:false,
processData: false,
contentType: false,
type: 'POST',
success: function(fd){
alert(fd);
}
});
My bad luck it is not hitting the code mentioned below. if it hits i may read the file. Vb.net Code
<WebMethod> _
Public Shared Function UploadFormDetails() As String
Dim httpPostedFile = HttpContext.Current.Request.Files("UploadedFile")
If httpPostedFile IsNot Nothing Then
' Get the complete file path
Dim fileSavePath = Path.Combine(HttpContext.Current.Server.MapPath("/Attachments/pdf/Forms/"), httpPostedFile.FileName)
' Save the uploaded file to "UploadedFiles" folder
httpPostedFile.SaveAs(fileSavePath)
End If
Return ""
End Function
Any body have any idea
Finally i made it happen by Handler File. I tried in many ways. But this is the only option worked out for me.
Please refer the code procedure here.
这篇关于VB.net文件上传使用的AjaxCall的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!