简体   繁体   English

将图像文件数据发送到RESTful服务

[英]Send Image File Data to RESTful Service

On my site I have an input element of type file (using it for camera capture on mobile devices). 在我的网站上,我有一个类型为fileinput元素(用于在移动设备上捕获相机)。 I want to send the data from the image to the server. 我想将数据从图像发送到服务器。 My problem is that I don't know the correct datatypes to use in this situation. 我的问题是我不知道在这种情况下要使用的正确数据类型。 I've tried using the FileReader API to get the data as a string and I always get a 413 (Request Too Large). 我尝试使用FileReader API将数据作为字符串获取,但我总是得到413(请求太大)。

All I want to do is have the user take a picture, send this picture to the server (so it can process off and save the EXIF data) and have the server return the data. 我要做的就是让用户拍照,然后将此图片发送到服务器(以便它可以处理并保存EXIF数据),然后让服务器返回数据。 I know how to read the EXIF data on the server, I know how to capture the image on the client, but I can't seem to get how to send the captured image data to the service correctly. 我知道如何读取服务器上的EXIF数据,我知道如何在客户端上捕获图像,但是似乎无法正确地将捕获的图像数据发送到服务。

Note: the server is C#. 注意:服务器是C#。

Thank you for your help. 谢谢您的帮助。

More information is needed regarding your C# webserver. 需要有关C#Web服务器的更多信息。

Hoever, in the example below, everywhere it says PHP-whatever, you have to know (or create) equivalent functionality in your C# webserver: 但是,在下面的示例中,无论哪里显示PHP,无论如何,您都必须知道(或创建)C#Web服务器中的等效功能:

http://www.w3schools.com/php/php_file_upload.asp http://www.w3schools.com/php/php_file_upload.asp

Also check out how to see html traffic in your browser when you run the above example: 另外,当您运行上述示例时,还请查看如何在浏览器中查看html流量:

http://msdn.microsoft.com/en-us/library/gg130952%28v=vs.85%29.aspx http://msdn.microsoft.com/zh-cn/library/gg130952%28v=vs.85%29.aspx

It might also be worth your time to know about jsbin and postimage to quickly try out examples: 也许还值得您花一些时间来了解jsbin和postimage来快速尝试一些示例:

http://code.tutsplus.com/tutorials/javascript-tools-of-the-trade-jsbin--net-36843 http://code.tutsplus.com/tutorials/javascript-tools-of-the-trade-jsbin--net-36843

http://postimage.org/about.php http://postimage.org/about.php

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM