2

i want to upload two files. here is the script

<?
    ini_set('memory_limit', "400M");
    ini_set('file_uploads', "5");
    ini_set('max_execution_time', "900");
    ini_set('upload_max_filesize', "400M");
    ini_set('post_max_size', "400M");
?>
<form action="form.php" method="post" enctype="multipart/form-data" />
<input type="file" name="video"  />
<input type="file" name="picture" >
<input type="submit"  class="input" value="Հիշել" />
</form>

form.php:

    <?
ini_set('memory_limit', "400M");
ini_set('file_uploads', "5");
ini_set('max_execution_time', "900");
ini_set('upload_max_filesize', "400M");
ini_set('post_max_size', "400M");
        print_r($_FILES);
       //returns Array ( )
    ?>

i've asked about this question here , and i've set ini_set(...) as you see, but when i try to upload the file greater than 50MB, it doesn't happen. could you tell me why?

update

YES, you're true i've print phpinfo(), and it shows, that upload_max_filesize is still 10MB. but why, if i wrote ini_set()?

Community
  • 1
  • 1
Simon
  • 22,637
  • 36
  • 92
  • 121

8 Answers8

4

There could be a restriction set by your web server; for example, you can set an Apache LimitRequestBody directive that can prevent uploading a large file.

Jacob Mattison
  • 50,258
  • 9
  • 107
  • 126
2

Check your php.ini file to see if there is a setting for the maximum upload size. You may not be able to override that setting in your PHP script.

Barry Brown
  • 20,233
  • 15
  • 69
  • 105
  • @Barry Brown i can i check it? – Simon Apr 09 '10 at 19:19
  • If you have access to your server's configuration files, yes. On a Linux host, it may be stored in /etc/php.ini or /etc/httpd/conf/php.ini. I'm not sure where it is kept on a Windows machine. Or do what @sologhost suggests: use phpinfo() to see what the settings are. – Barry Brown Apr 09 '10 at 19:30
1

The web server also controls (limits) the upload size. You should verify the maximum upload size in your web server configuration.

Best Regards, Don

Don Dickinson
  • 6,200
  • 3
  • 35
  • 30
1

To verify webserver configuration, create a php file with the following code:

<?php
phpinfo();
?>

This will tell you all the configuration that, I believe, Don is talking about. Upload it to your server, and run it in your browser.

Barry Brown
  • 20,233
  • 15
  • 69
  • 105
SoLoGHoST
  • 2,673
  • 7
  • 30
  • 51
1

The person in the previous question was wrong. upload_max_filesize and post_max_size are marked as PHP_INI_PERDIR:

upload_max_filesize     "2M"    PHP_INI_PERDIR      PHP_INI_ALL in PHP <= 4.2.3.
post_max_size   "8M"    PHP_INI_PERDIR      PHP_INI_SYSTEM in PHP <= 4.2.3. Available since PHP 4.0.3.

-- PHP Manual, Description of core php.ini directives

PHP_INI_PERDIR can not be changed with ini_set:

Entry can be set in php.ini, .htaccess or httpd.conf

-- PHP Manual page "Where a configuration setting may be set"

Use one of his other methods to change the value instead.

Powerlord
  • 87,612
  • 17
  • 125
  • 175
1

You can't simply ini_set all php configuration variables, some of them should be set before processing any php file.

You can change them in php.ini or in .htaccess like this:

<IfModule mod_php5.c>
  php_value post_max_size 50M
  php_value upload_max_filesize 50M
</IfModule>
dev-null-dweller
  • 29,274
  • 3
  • 65
  • 85
0

In some web servers, some ini_set() values are ignored. Contact your host, sometimes they will let you upload a custom php.ini file with the maximum upload size you require.

metrobalderas
  • 5,180
  • 7
  • 40
  • 47
0

Smply create a php.ini file in your /public_html/ folder or if it already exists then edit them.

post_max_size = 128M
upload_max_filesize = 128M

that is it.