简体   繁体   English

通过C#将图片上传到ASP.NET MVC 3操作

[英]Uploading Pictures via C# to ASP.NET MVC 3 Action

I'm working on a Windows Phone 7 app. 我正在使用Windows Phone 7应用程序。 This app will empower people to upload pictures. 此应用程序将使人们能够上传图片。 My backend uses ASP.NET MVC 3. Right now, people can upload pictures. 我的后端使用ASP.NET MVC3。现在,人们可以上传图片。 What I'm discovering though is that some of these pictures are not uploaded properly. 我发现,其中有些图片没有正确上传。 Oddly, the picture is half uploaded, but the bottom half is purely gray. 奇怪的是,图片上载了一半,但下半部分是纯灰色的。

I can't even think of a scenario where this would happen. 我什至无法想到会发生这种情况的情况。 Can somebody help me identify how this would even happen? 有人可以帮助我确定这种情况如何发生吗? Basically, a picture gets uploaded. 基本上,图片被上传。 The top half looks right. 上半部分看起来正确。 The bottom half is pure gray. 下半部分为纯灰色。 It only happens occasionally. 它只是偶尔发生。 I have not been able to reproduce the problem myself. 我自己无法重现该问题。 I only see that some of the photos that are being uploaded from my users have this. 我只看到从我的用户上传的一些照片具有此功能。

This can occur if pictures are not fully uploaded, if, for example your user stops uploading in middle of the process. 如果图片未完全上传,则可能发生这种情况,例如,您的用户在过程中途停止上传。

By stopping, it can be a connectivity loss, application close, whatever. 如果停止,则可能会导致连接丢失,应用程序关闭等。

You should check the upload is fully done before "validating" your data (IE check image file size against content-length of POST request). 您应在“验证”数据之前检查上传是否已完成(IE检查图像文件大小是否符合POST请求的内容长度)。

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

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