公共的環境前段
<form enctype="multipart/form-data" action="upload.php" method="POST">
<!-- MAX_FILE_SIZE must precede the file input field -->
<input type="hidden" name="MAX_FILE_SIZE" value="100000000" />
<!-- Name of input element determines name in $_FILES array -->
Send this file: <input name="userfile" type="file" />
<input type="submit" value="Send File" />
</form>
nginx+linux環境注意事項
php環境上傳大文件需要注意的事項:
/usr/local/php/etc/php-fpm.conf.default
request_terminate_timeout = 0 //這個是fastcgi的執行時間,默認不限制的
client_max_body_size 256m;
fastcgi_buffer_size 256k;
fastcgi_buffers 16 256k;
fastcgi_busy_buffers_size 256k;
fastcgi_temp_file_write_size 256k;
fastcgi_connect_timeout 3000;
fastcgi_send_timeout 3000;
fastcgi_read_timeout 3000;
另外PHP也需要配置:
memory_limit 512M
max_execution_time 0
post_max_size 256M
upload_max_filesize 256M
apache+windows環境下注意事項
配置php.ini文件 (以上傳500M以下大小的文件為例)
查找以下選項並修改->
file_uploads = On ;打開文件上傳選項
upload_max_filesize = 500M ;上傳文件上限
如果要上傳比較大的文件,僅僅以上兩條還不夠,必須把服務器緩存上限調大,把腳本最大執行時間變長
post_max_size = 500M ;post上限
max_execution_time = 1800 ; Maximum execution time of each script, in seconds腳本最大執行時間
max_input_time = 1800 ; Maximum amount of time each script may spend parsing request data
memory_limit = 128M ; Maximum amount of memory a script may consume (128MB)內存上限