处理器接收不到图像

处理器接收不到图像

本文介绍了MVC3 - 文件上传控制器/处理器接收不到图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用
文件上传插件做ajax的图片上传,我看到在提琴手的要求办理,并在它的形象时,我挑一个地方的形象。该提琴手请求中有PNG文件

I am using http://valums.com/ajax-upload/File uploader plugin to do ajax image upload and i see the request in fiddler go through, with the image in it when i pick a local image. The fiddler request has the PNG file in it.

从小提琴手 -

POST http://localhost:16169/client/account/uploadimage/202?qqfile=logo_l.png HTTP/1.1
Host: localhost:16169
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:6.0.2) Gecko/20100101 Firefox/6.0.2
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip, deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Connection: keep-alive
X-Requested-With: XMLHttpRequest
X-File-Name: logo_l.png
Content-Type: application/octet-stream
Referer: http://localhost:16169/client/events/edit/202
Content-Length: 32660
Pragma: no-cache
Cache-Control: no-cache

�PNG

���
IHDR�����������¯�C���gAMA����
�a���   pHYs�����&�?���tEXtSoftware�Microsoft Office�5q��IDATx^��G�=���8,����@p
�ݓ�@�$��������.+��T���H���ϗ}��<��ܹsgg�O�����6111A���A2�@J�%�K!��K��)����ζ)�Mm��@�{�;ˤ�
ˤt�d���FK���og�Ц�6�a �=�eR�?�eR:m2�@J�%�F���m
hS@��0�����2)��2)�6b �ђa����6�)�MvHv�og���Oa��N�1��hɰ���l���&;$����L����LJ�M�Hi�d�h�v�Mm

我已经截断了请求,但你得到的图像在后体内所发送的想法。

I have truncated the request but you get the idea that the image is being transmitted in the post body.

但是当我做

var image = WebImage.GetImageFromRequest();

在处理这个post请求控制器。图片出来为空,看着调试所有其他值都存在。

in the controller that handles this post request. Image comes out to be null, Looking at the debugger all other values are present.

Request.Files.Count = 0

以及

任何人都通过这个走了,或者可以帮我调试此将不胜感激。谢谢你。

Anyone gone through this, or can help me debug this will be greatly appreciated. Thanks.

推荐答案

找到了解决办法。

 WebImage image = new WebImage(Request.InputStream);



而不是 -

instead of -

var image = WebImage.GetImageFromRequest();

这篇关于MVC3 - 文件上传控制器/处理器接收不到图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 22:05