HTML输入文件.您如何获取文件? [英] HTML Input file. How do you get the file?

查看:70
本文介绍了HTML输入文件.您如何获取文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此,我有一个类型为file的HTML输入.我想触发一种使用Ajax将文件发布到我的ASMX Web服务的方法.老实说,我已经用Google搜索了,不知道该怎么办.这是我所拥有的:

So I have an HTML input of type file. I want to fire a method that posts the file to my ASMX web service using Ajax. I honestly have Googled and have no idea what to do. Here is what I have:

<script type="text/javascript">
        function Upload() {
            //Post data here
        }
    </script>

<input id="fuFile" type="file"  önchange="Upload()" />



我不知道如何从文件输入中提取"文件.一旦到达我的Web服务,我将需要文件的byte []和MIME类型,因为我会将其保存在数据库中.

感谢您的帮助.



I have no idea how to "extract" the file from the file input. Once it reaches my web service, I am going to need the byte[] of the file and the MIME type as I will then save this in the database.

Thanks for the help.

推荐答案

1.创建一个表单.
2.将文件输入控件放入该表单中.
3.将表单的发布网址设置为您选择的Web服务器.
4.获取您的JavaScript以调用表单的Submit事件.
1. Create a form.
2. Put your file input control inside that form.
3. Set the post url of the form to the webserver of your choice.
4. Get your javascript to call form''s submit event.


这篇关于HTML输入文件.您如何获取文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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