0

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

2
  • 2
    i assume you've changed this line : <input type="hidden" name="MAX_FILE_SIZE" value="100000000" /> otherwise there's your problem Commented Apr 9, 2010 at 16:21
  • @oedo i've tried and with that line, and without. Commented Apr 9, 2010 at 16:26

2 Answers 2

7

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">
Sign up to request clarification or add additional context in comments.

11 Comments

@John Conde is there any function to do this( like ini_set())?
MAX_FILE_SIZE is only a HINT for your browser and does not specify the limit PHP accepts for file uploads.
@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.
@John Conde thanks much:) and what is the highest limit of that size?
@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.
|
1

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.