tags:

views:

108

answers:

7

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()?

+1  A: 

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
@Don Dickinson how can i do this?
Syom
+4  A: 

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.

JacobM
@JacobM could you give a link, or tell me how can i do that?
Syom
+1  A: 

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.

SoLoGHoST
It's phpinfo(); not php_info();
Tim Green
Thanks, my bad, opps
SoLoGHoST
A: 

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
+2  A: 

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
@Barry Brown i can i check it?
Syom
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
+1  A: 

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.

R. Bemrose
A: 

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