0

Ok.. say I have a music service, how can I increase the maximum file upload size for that specific page so it won't time out if a large file is chosen?

Ok, I know you can tinker with the php.ini file by changing

memory_limit = 32M
upload_max_filesize = 10M
post_max_size = 20M

, but then that sets that globally.

pshahab48
  • 31
  • 6
  • 1
    There's ini_set in PHP, which changes a php.ini setting only for the script execution – mcont Jan 02 '15 at 11:56

3 Answers3

1

You may want to change the maximum upload file size for your web site. For example, you can set a lower limit to prevent users from uploading large files to your site. To do this, change the upload_max_filesize and post_max_size directives in an .htaccess file.

To change the maximum upload file size for your PHP scripts, follow these steps:

Log in to your account using SSH.
Use a text editor to add the following line to the .htaccess file. Replace xx with the maximum upload file size that you want to set, in megabytes:

php_value upload_max_filesize xxM

Add the following line to the .htaccess file. Replace xx with the maximum HTTP POST file size that you want to set, in megabytes:

php_value post_max_size xxM

Save the changes to the .htaccess file and exit the text editor. To verify that the new setting is active, create a PHP test file that contains the following code in the same directory where the .htaccess file is located:

Load the test file in your web browser, and then search for the name of the directive. The Local Value column should display the new setting that you specified in the .htaccess file.

for more detail http://www.cyberciti.biz/faq/linux-unix-apache-increase-php-upload-limit/

or

<?php

// Define file size limit
$limit_size=50000;

  code......

$file_size=$HTTP_POST_FILES['ufile']['size'];

if($file_size >= $limit_size){
echo "Your file size is over limit<BR>";
echo "Your file size = ".$file_size;
echo " K";
echo "<BR>File size limit = 50000 k";
}
else {

   code............
Akash kumar
  • 981
  • 3
  • 14
  • 27
  • No need to do it through .htaccess for I have full server access with my vpn. Again, that will be setting it for my web site, which I do not want. I was hoping there was some php syntax to increase it for a specific uploader. Guess not. – pshahab48 Jan 02 '15 at 11:58
  • for >2mb why not you reffer -: http://www.phpeasystep.com/phptu/3.html http://stackoverflow.com/questions/9153224/how-to-limit-file-upload-type-file-size-in-php – Akash kumar Jan 02 '15 at 12:01
0

See PHP change the maximum upload file size for different available methods.

You can use multiple upload pages (depending on the uploader limit you want to set), stored in different directories, with different .htaccess configurations, which would allow you to group your users by upload limit.

Community
  • 1
  • 1
sodawillow
  • 12,497
  • 4
  • 34
  • 44
-1

add this to your php

; Maximum allowed size for uploaded files.
upload_max_filesize = 40M

; Must be greater than or equal to upload_max_filesize
post_max_size = 40M