本文介绍了图片上传 - 本地主机中断的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我实现了一个小方法
我的网站,我上传图片。采用FileUpload控件,我选择图像,然后当我打一个按钮,生成 UploadImage()方法。

I have implemented a small methodfor my site where I upload an image. using a FileUpload control, I choose an image, and then when I hit a button, the UploadImage() method is generated.

UploadImage()方法存储图像的文件夹中的服务器和存储其在数据库路径。它还检查图像文件的大小,如果大于一兆字节,则显示一个警告,否则,图像上传和存储。这已经测试了一些图片,从45KB到900KB。它完美。

The UploadImage() method stores the image in a folder in the server and stores its path in the Database. It also checks the file size of the image, if greater than a megabyte, an alert is displayed, else, the image is upload and stored. This has been tested with a few images ranging from 45KB to 900KB. It has worked perfectly.

问题:

在大约4MB的一些图片进行测试,有时显示错误,因为它是大于1MB,但在其他时间(我不知道为什么),谷歌Chrome指引我到一个页面,告诉我,本地主机已经中断。

When tested with a few images of approximately 4MB, sometimes it shows the 'error' since it is greater than 1MB, but at other times (I do not know why), Google Chrome directs me to a page telling me that the localhost has been interrupted.

在调试时,我甚至不进入按钮上传点击的方法!我觉得这很奇怪。图像的扩展似乎并不成为问题,因为我以.jpg和.png测试。

When debugging, I do not even enter the button Upload click method! I find this very strange. The extension of the image doesn't seem to be the problem since I am testing with .jpg and .png.

难道有人遇到同样的问题?是否有一个大师,可以帮助我?

Did some one experience the same problem? Is there a guru that can help me?

非常感谢你。

更新:

似乎4052kb的文件已正确地工作(被显示即错误消息)
但超过4098kb文件)产生了一个本地主机中断。当按钮被点击时,
在浏览器下方显示发送请求,并上传(0%),并显示本地主机的连接被中断。

it seems that files of 4052kb have worked correctly (i.e. an error message was displayed)but files over 4098kb) resulted in a local host interrupt. When the button is clicked, the browser below shows 'sending request' and uploading (0%) and displays "The connection to localhost was interrupted."

推荐答案

请看看在的maxRequestLength 的httpRuntime web.config中的元素

http://msdn.microsoft.com/en-us/library/e1f13641.aspx

这是你设置的最大请求长度。当超过时,运行时会抛出异常。默认大小为4096KB。

This is where you set the maximum request length. When it is exceeded, the runtime throws an exception. The default size is 4096KB.

这篇关于图片上传 - 本地主机中断的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-15 03:13