file upload problem

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
susrisha
Forum Contributor
Posts: 439
Joined: Thu Aug 07, 2008 11:43 pm
Location: Hyderabad India

file upload problem

Post by susrisha »

1. I have a form to upload a file of size more than the limit specified in php.ini(Say 2MB)
2. I have created a php.ini in the same directory to overwrite the specifications in the directory.(say 12MB)
3. I have created an upload form and tried to upload the file a file of higher size(say 5MB)
4. I get an error 2 ($_FILES['uploadedfile']['error'])

How do i resolve this problem?
User avatar
jaoudestudios
DevNet Resident
Posts: 1483
Joined: Wed Jun 18, 2008 8:32 am
Location: Surrey

Re: file upload problem

Post by jaoudestudios »

In the php.ini file there are a few locations you need to modify.

Something like this...
upload_max_filesize
post_max_size
User avatar
jaoudestudios
DevNet Resident
Posts: 1483
Joined: Wed Jun 18, 2008 8:32 am
Location: Surrey

Re: file upload problem

Post by jaoudestudios »

Do you have enctype="multipart/form-data" in your form tag?
User avatar
susrisha
Forum Contributor
Posts: 439
Joined: Thu Aug 07, 2008 11:43 pm
Location: Hyderabad India

Re: file upload problem

Post by susrisha »

yes i did..
and i think i found out the problem.

in the uploading form i had a hidden field

Code: Select all

 <input type="hidden" name="MAX_FILE_SIZE" value=1000000/> 
This was initially put for verification on client side. But i see that the latest php versions also check for this field by default and if the uploaded file exceeds this limit, it will bounce back this error.

And FYI , i have increased both the max_file_size as well as the post data maximum size to 20MB. So no issues there.
Post Reply