一、問題概述:
最近開發上傳視訊檔案的功能。基本流程已經跑通了,可是上傳30M以上的檔案時就會報錯。
二、資料海洋瞎撲騰
從網上查了一些資料,一般都是下面這種說法:
看着步驟倒是也不算繁瑣,可是本人照着步驟做了卻沒找到所說的<requestLimits>節點。無奈了。如果有高人明白咋回事的話麻煩指點下。。。
三、暮然回首,答案就在燈火闌珊處
其實上面分析的錯誤原因是對的,就是IIS中允許上傳的最大檔案預設是20多M,是以當上傳較大的檔案時才會報這個錯誤。後來用另外一種途徑修改了這種設定。
目标是要修改檔案C:\Windows\System32\inetsrv\config\schema\IIS_schema.xml 。綠色下劃線部分使我們要修改的目标位置。
<a></a>
<element name="requestLimits">
<attribute name="maxAllowedContentLength" type="uint" defaultValue="30000000" />
<attribute name="maxUrl" type="uint" defaultValue="4096" />
<attribute name="maxQueryString" type="uint" defaultValue="2048" />
<element name="headerLimits">
<collection addElement="add" clearElement="clear" removeElement="remove">
<attribute name="header" type="string" required="true" isUniqueKey="true" validationType="nonEmptyString" />
<attribute name="sizeLimit" type="uint" required="true" />
</collection>
</element>
問題在于,這個檔案是隻讀的,即使用管理者權限也不能修改。要先修改檔案的權限,然後去掉隻讀屬性才可以。
1.右鍵檔案->屬性->安全,選中目标使用者,點選進階,修改檔案所有者;
2.确定後點選編輯,就可以修改目前使用者的權限了,添加“寫入”權限。至此,權限設定OK了。
3.将檔案的隻讀屬性去掉。
4.以管理者身份打開VS,然後在VS中編輯目标XML檔案,修改所需位置即可。
5.上傳個100M的視訊,OK了。
至此,大功告成。
本文轉自 陳敬(Cathy) 部落格園部落格,原文連結:http://www.cnblogs.com/janes/archive/2010/11/18/1881069.html,如需轉載請自行聯系原作者