如何使用Asp.Net MVC上传文件使用WCF Rest使用Jqury-Ajax调用而不使用页面刷新 [英] How to upload a file using Asp.Net MVC Using WCF Rest With Jqury-Ajax Call Without Page Refresh

查看:43
本文介绍了如何使用Asp.Net MVC上传文件使用WCF Rest使用Jqury-Ajax调用而不使用页面刷新的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



我需要你的指南,如何从Asp.net MVC上传文件使用从Jquery-Json / Jquery调用的WCF Rest服务没有页面刷新的Ajax。我不想使用Ajax Update面板或其他东西。我想在没有页面刷新的情况下上传文件WCF Rest.If它可以将文件存储在数据库中,转换成字节OR或者可以上传一个存储在服务器文件夹上的文件。如果是的话如何。如果有人有想法请分享。真的很感谢我。谢谢。



热烈的关注



KP Singh Chundawat

Hello folks,

I am needed your guide that how to upload a file from Asp.net MVC Using WCF Rest service calling from Jquery-Json/Jquery-Ajax without page refresh .I don't want to use Ajax Update panel or something other .i want to upload file without page refresh WCF Rest.If its is possible to store file in database which is converted into byte OR it is possible to upload a file which is store on server folder .if yeah then how to .if anyone have idea please share .its really appreciated me.Thanks in advance .

Warm Regard

KP Singh Chundawat

推荐答案

要在没有POST请求(页面刷新)的情况下上传文件,您需要客户端框架。 JavaScript就是其中之一。您应该使用jQuery来简化操作。



您可以创建一个新的ajax请求(需要Ajax请求,没有其他方法可以发送数据到服务器而不创建新的ajax请求)。您可以将表单数据传递给该请求,它会将数据发送到您的服务器。



在开始时理解和概念化是一个技术性的东西,但随着时间的推移,你会理解。阅读我的文章,使用jQuery将文件发送到服务器:上传文件 - HTML5和jQuery方式! [ ^ ]。



就存储服务器上的文件而言,我会将文件保存在文件系统中,而不是将文件存储在数据库中。数据库空间非常昂贵且成本高昂,您还必须有效地管理空间。因此浪费那些字节的空间将是愚蠢的。我建议您将这些文件存储在文件系统中,在大多数情况下 Unlimited



但是,我不是了解为什么需要WCF参与?如果不知怎的,仍然需要使用WCF,您应该了解客户端及其发送数据的方法以及所有这些内容。 http://msdn.microsoft.com/en-us/library/ dd456779%28v = vs.110%29.aspx [ ^ ]
To upload the files without a POST request (page refresh) you would need a client-side framework. JavaScript is one of them. You should be using jQuery, to make things easier.

You can create a new ajax request (Ajax request is required, there is no other way for you to send the data to the server without creating a new ajax request). You can pass the form data to that request, and it will send the data on to your servers.

It is a little technical thing to understand and conceptualize in the beginning but as time passes you will understand. Read my article on sending the files to the server using jQuery: Uploading the files – HTML5 and jQuery way![^].

As far as storing the files on the server is concerned, I would go with saving the files on the file system, rather than storing the files in the database. The database space is really expensive and costly, and you also have to manage the space efficiently. So wasting those bytes of space would be foolish. I would recommend that you store those files on the file system, which in most of the cases are Unlimited.

However, I am not understanding why do you need the WCF to involve? If somehow, still you need to consume WCF, you should learn about the client's and their methods to send the data, and all that stuff. http://msdn.microsoft.com/en-us/library/dd456779%28v=vs.110%29.aspx[^]


感谢Ahmad Zeeshan先生......是的,如果有可能使用Jqury那就好了。请发布给我代码的想法..实际上我的要求是客户端的文件上载或没有页面刷新....谢谢
Thanks for this Ahmad Zeeshan sir...yeah that is good if it is possible using Jqury..Please give me Code idea ..Actually my requirement is that fileupload in Client side or Without Page Refresh ....Thanks


这篇关于如何使用Asp.Net MVC上传文件使用WCF Rest使用Jqury-Ajax调用而不使用页面刷新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆