Image Upload - Local host interrupt

独自空忆成欢 提交于 2019-12-10 17:38:12

问题


I have implemented a small method for 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.

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.

THE PROBLEM:

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.

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?

Thank you very much.


update:

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."


回答1:


Please take a look at the maxRequestLength of the httpRuntime element of the web.config.

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

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



来源:https://stackoverflow.com/questions/8114571/image-upload-local-host-interrupt

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!