我如何...如何在ASP.NET webmethod中传递文件 [英] How do i...how to pass file in ASP.NET webmethod

查看:54
本文介绍了我如何...如何在ASP.NET webmethod中传递文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将上传的文件传递给带有其他参数的asp.net webmethod。

我知道如何使用处理程序。但我的功能就像是,



[webmethod]

public static void(string name,??)

{

这里我将asmx webservice称为传递名称。现在我怎样才能传递上传的文件?从jquery ajax调用传递什么类型的参数(代替?),以便我可以将其传递给asmx服务?

}



在处理程序中,我无法在单个函数中执行此操作。这里的概念是,首先保存名称,从sql返回唯一的id,然后我将文件命名为id并保存到文件夹。我必须在asmx webservice中完全编写保存概念。



因此,如果我可以使用name参数从jquery / ajax调用传递文件,那将是最好的显然,但你可以告诉其他方法。



我尝试过:



我尝试使用处理程序但无法实现我的需要。

I want to pass uploaded file to asp.net webmethod with other parameters.
I know how to use handlers. But my function is like,

[webmethod]
public static void(string name,??)
{
here I call asmx webservice to pass name. now how can I pass the file uploaded? What type of parameter to pass(in place of??) from jquery ajax call so that I can pass that to asmx service?
}

In handler I can't do this in a single function. Here concept is,first the name will be saved,unique id will be returned from sql,then I'll name the file with the id and save to folder. The saving concept I have to write fully in the asmx webservice.

So if I can pass the file from jquery/ajax call with the name parameter,that will be best obviously,but you can tell other methods.

What I have tried:

I tried with handlers but can't achieve what I need.

推荐答案

你可以使用文件阅读器 [ ^ ]。



将内容发送到服务器端,然后使用该二进制数据。
You can use FileReader[^].

Send the contents to server side and then work with that binary data.


这篇关于我如何...如何在ASP.NET webmethod中传递文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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