This is an old revision of the document!
Upload Large Files
In many site applications, user can upload files, some could be big file , like 1GB or bigger, but when upload such large file, many setting could have put a limit on it and cause you failed to upload it, here are some setting you may need to check when have upload failure on large file.
On external app part (typically PHP), you may need to check :
1. upload_max_filesize
2. post_max_size
3. max_execution_time (some PHP script may need to do some afterward process, like resizing or watermarking, so max_execution_time could also affect it)
4. memory_limit
5. upload_tmp_dir (by default this would be /tmp , many system comes with default as 2GB in size , which if you upload a file bigger than 2GB, then it will undoubtedly fail because not enough disk space to save temporary file.)
If your /tmp is too small and can not resize it , you can choose to change the location, e.g. to /var/tmp
This setting can not be override by .htaccess , it must be set in php.ini.
and make sure the new directory has permission to allow PHP user to read/write files, if you have open_basedir in action , make sure new path is included.
On LiteSpeed WebServer part, you may need to check:
1. Swapping Directory in Server Configuration > General (same reason for PHP's upload_tmp_dir )
You can change it to somewhere like /var/tmp/lshttpd/swap
, default ownership and permission as follow, you should make it same.
[root@test ~]# ls -l /tmp/lshttpd/ | grep swap drwxr-x--x 22 nobody nobody 4096 Aug 22 17:35 swap
2. Max Request Body Size (bytes) in Server Configuration > Tuning
3. External App Timeout , please check this page for further detail.
4. Memory Soft Limit (bytes) and Memory Hard Limit (bytes) in External App , if you don't see any PHP shows up in External App then please go to PHP tab instead, raise from default ``2047M`` to a higher number , you can blindly raise it to something like `20470M` for test purpose.
5. wait-req-full-body , please check this page for further detail.
Check and Test
Here is a simple PHP upload script , you can use it to test the upload with large files.
<?php ini_set('display_errors', 1); ini_set('display_startup_errors', 1); error_reporting(E_ALL); echo "uplaod max size: ".ini_get('upload_max_filesize'); echo "<br>"; echo "post max size: ".ini_get('post_max_size'); echo "<br>"; echo "max execution time : ".ini_get('max_execution_time'); echo "<br>"; echo "memory limit: ".ini_get('memory_limit'); echo "<br>"; echo "upload tmp dir: ".ini_get('upload_tmp_dir'); echo "<br>"; echo "<br>"; if(isset($_FILES['test'])){ $errors= array(); $file_name = $_FILES['test']['name']; $file_size =$_FILES['test']['size']; $file_tmp =$_FILES['test']['tmp_name']; $file_type=$_FILES['test']['type']; if (!file_exists('upload_test')) { mkdir('upload_test', 0777, true); } if(empty($errors)==true){ move_uploaded_file($file_tmp,"upload_test/".$file_name); echo "Success"; }else{ print_r($errors); } } ?> <html> <body> <form action="" method="POST" enctype="multipart/form-data"> <input type="file" name="test" /> <input type="submit"/> </form> </body> </html>
this will simply to determinate if there is something wrong with PHP/LSWS or your site application.
If this script uploading works , but your site's uploading is not working properly , then probably something wrong in your site code , you may need to check on that.