1

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?

4 Answers 4

4

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

9 Comments

how can i rename a txt file to become .htaccess
if you are using windows then open a notepad > save as > choose all file types and give the filename as .htaccess
If you are using windows you may not be using apache and an .htaccess file won't work
can you check your maximum upload filesize limit with this code. <?php echo $max_upload = (int)(ini_get('upload_max_filesize')); ?>
well, i do have a apache and mysql server running
|
1

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.

2 Comments

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

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.

2 Comments

where can i find the php.ini when im running the page through eayphp?
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.
0

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

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.