tags:

views:

65

answers:

2

i have the form, and i want to upload two files. here is the script

<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="Հիշել" />
<input type="hidden" name="MAX_FILE_SIZE" value="100000000" />
</form>

form.php:

<?
    print_r($_FILES);
    $video_name = $_FILES["video"]["name"];
    $image_name = $_FILES["picture"]["name"];
    echo "video",$video_name;
    echo "image",$image_name;
                              //returns Array ( ) videoimage
?>

when i try to upload the file greater than 10MB, it doesn't happen. i try in many browsers. maybe i must change some field in php.ini? but i haven't permission to change them on the server. so what can i do? thanks

+4  A: 

File Uploads - Common Pitfalls

The MAX_FILE_SIZE item cannot specify a file size greater than the file size that has been set in the upload_max_filesize in the php.ini file. The default is 2 megabytes.

If a memory limit is enabled, a larger memory_limit may be needed. Make sure you set memory_limit large enough.

...

If post_max_size is set too small, large files cannot be uploaded. Make sure you set post_max_size large enough.

You can increase the value for MAX_FILE_SIZE three four ways:

1) php.ini

upload_max_filesize = 20M
post_max_size = 20M

2) ini_set()

ini_set('upload_max_filesize', 20M);
ini_set('post_max_size', 20M);

3) .htaccess

php_value upload_max_filesize 20M
php_value post_max_size 20M

4) hidden form fields

<input name="MAX_FILE_SIZE" value="20971520" type="hidden">
John Conde
@John Conde is there any function to do this( like ini_set())?
Syom
MAX_FILE_SIZE is only a HINT for your browser and does not specify the limit PHP accepts for file uploads.
Robert
@Syom - I've updated my answer to reflect usage of ini_set()
John Conde
@Robert: The browser doesn't understand `MAX_FILE_SIZE` as anything but a form field. It's PHP that uses this value, but it can't override the ini setting.
R. Bemrose
@John Conde thanks much:) and what is the highest limit of that size?
Syom
@Syom, It's whatever you want it to be (assuming you have control over server settings). On my dedicated server it is set to 100M since we have clients who upload large files.
John Conde
@John Conde hmmmmmmm:( i've set the max_size 200M, but i can't upload greater than 55M. i also set ini_set('max_execution_time', "900");
Syom
@Syom Some other setting might be limited to 55M. phpinfo() should show you all of the ini settings and what there values are.
John Conde
@John Conde yes, when i print phpinfo() it shows, that post_max_size is 64MB, but i set 400MB. could you tell me how it happens? thanks much John
Syom
As I noted elsewhere, you can not use ini_set with these directives as they are marked `PHP_INI_PERDIR`.
R. Bemrose
@UNICORNS: I just checked http://php.net/manual/en/features.file-upload.post-method.php against http://php.net/manual/de/features.file-upload.post-method.php and the german translation says "MAX_FILE_SIZE" is a hint for the browser whereas the english original refers about a PHP 1st-level-check for file uploads.
Robert
+1  A: 

In your php.ini, adjust the upload_max_filesize directive. Also set the memory_limit to a higher number.

jweyrich