PHP + Uploadify + MySQL上傳大檔案出現HTTP Error (500)
網頁程式碼,裝入Uploadify控制元件:
<script src="uploadify/jquery.uploadify.min.js" type="text/javascript"></script>
<script src="uploadify/swfobject.js" type="text/javascript"></script>
<div id ='divFileUpload' class='div6' style='padding:5px' >
<div class='span3A' onclick="GetMyFileProcessStatus()" title='Click here to get file processing status' >Click (+) to upload cad file (*.zip;*.rar;*.tgz)<hr /></div>
<input id="file_upload" name="file_upload" type="file" multiple="true" />
<div id='div_fileuploadstatus'></div>
<div id='divfileQueue'></div>
<div id='divFileList' >File list</div>
<div id='divFileInfo' ></div>
</div>
uploadify: http://www.uploadify.com/demos/
問題:大檔案上傳,錯誤
Uploadify small file to MySQL, good; (3M小檔案上傳,沒有問題)
Uploadify big file to MySQL, error: (100M大檔案上傳,錯誤)
思路:
- 1)可能在某個地方設定了限定上傳檔案大小
- 2)上傳檔案需要時間,可能在某個地方設定了限定上傳檔案的時間
1. 檢查PHP ini (問題在於PHP配置檔案設定裡)
echo ini_get('upload_max_filesize')."<br />";
>2048M (此設定沒有問題)
echo ini_get('post_max_size');
>1024M (此設定沒有問題)
max_execution_time = 300 改為 3000
max_input_time = 60 改為 600
memory_limit = 128M 改為 1280M
(after change to the red, restart IIS …. upload big file …. 修改以上引數之後,上傳檔案就沒有問題了)
2. 檢查mysql 設定(沒有問題)
mysql> show VARIABLES like'%max_allowed_packet%';
+--------------------------+------------+
| Variable_name | Value |
+--------------------------+------------+
| max_allowed_packet | 1073741824 |
| slave_max_allowed_packet | 1073741824 |
+--------------------------+------------+
2 rows in set (0.00 sec)
3. 檢查IIS configuration (IIS配置,沒有問題)
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.5" />
<!--maxRequestLength就是檔案的最大字元數,最大值不能超過2個G左右,executionTimeout是超時時間-->
<httpRuntime targetFramework="4.5" maxRequestLength="1073741824" executionTimeout="3600" />
</system.web>
<system.webServer>
<handlers accessPolicy="Read, Execute, Script">
<remove name="perlFastCgiModule" />
<add name="perlFastCgiModule" path="*.pl" verb="*" modules="FastCgiModule" scriptProcessor="C:\Perl64\bin\perl.exe "%s" %s" resourceType="Either" requireAccess="Script" />
</handlers>
<security>
<requestFiltering allowDoubleEscaping="true">
<requestLimits maxAllowedContentLength="1073741824"/>
<fileExtensions allowUnlisted="true"/>
<verbs allowUnlisted="true"/>
</requestFiltering>
</security>
</system.webServer>
</configuration>
4. 檢查PHP ini設定
echo ini_get('upload_max_filesize')."<br />";
>2048M
echo ini_get('post_max_size');
>1024M
max_execution_time = 300 改為 3000
max_input_time = 60 改為 600
memory_limit = 128M 改為 1280M
(after change to the red, restart IIS …. upload big file …. good! 修改以上引數之後,上傳檔案就沒有問題了)