views:

43

answers:

4

hi everone. I searched around google and stackoverflow, but didnt quite find the right answer.

im using a form. Within this form i have a simple uploader

<form method="post" action="uploadImage.php" enctype="multipart/form-data">
   <input name="upload" id="upload" type="file" />
   <input name="add" type="submit" id="add" value="add">
</form>

Now, in my uploadImage.php file, i have written, below

print "<pre>";
print_r($_FILES['upload']);
print "</pre>";

when i upload a image with filesize about below 1.5MB, an array with info of that file is returned. But when i upload a file with about 2MB size, i get 1 error, and no filesize. when i upload a 8MB file i get this error, Notice: Undefined index: upload in C:\Program Files........\uploadImage.php on line 2

I think the problem has something to do with upload limitations, the question is how can i fix this?

A: 

php.ini has directives that control max upload size, specifically post_max_size and upload_max_filesize, the latter of which defaults to 2M. Look here.

Tesserex
where can i find the php.ini when im running the page through eayphp?
mana
i would not recommend directly editing the php.ini file because most of the host won't allow you to do it. it is always better to use .htaccess instead.
Ibrahim Azhar Armar
A: 

In php.ini you need to edit the line upload_max_filesize to a higher value. 2MB is the default limit.

Gazler
A: 

create a .htaccess file in your root folder and put the following code in it.

php_value upload_max_filesize 20M
php_value post_max_size 20M
php_value max_execution_time 200
php_value max_input_time 200
Ibrahim Azhar Armar
how can i rename a txt file to become .htaccess
mana
that did not help
mana
if you are using windows then open a notepad > save as > choose all file types and give the filename as .htaccess
Ibrahim Azhar Armar
If you are using windows you may not be using apache and an .htaccess file won't work
adam
can you check your maximum upload filesize limit with this code. <?php echo $max_upload = (int)(ini_get('upload_max_filesize')); ?>
Ibrahim Azhar Armar
well, i do have a apache and mysql server running
mana
@adam he said he is using easyphp which means it is another version of WAMP.
Ibrahim Azhar Armar
by the way, what does these two commands mean?php_value max_execution_time 200php_value max_input_time 200
mana
php_value max_execution_time Limits the maximum execution time, max_input_time determines how much time PHP will wait to receive file data
Ibrahim Azhar Armar
have a look at this article this may help solve your problem http://blog.jc21.com/2007-05-03/change-the-maximum-upload-size-with-php/
Ibrahim Azhar Armar
@Ibrahim apologies. I can't see where he's said that though...
adam
@adam he said eayphp and i got the point.
Ibrahim Azhar Armar
+1  A: 

That first error is because you hit upload_max_filesize limit, and that another notice comes when you hit post_max_size.

post_max_size generally should be set to a higher value than upload_max_filesize since there is some extra overhead/bytes involved.

Sim
oki, i think i got it now. Found out where php.ini is on my simulated server.
mana
tnx.............
mana
nice, it works now everyone. Tnx for explaning this to me in detail.
mana