Solved

Increase max_upload_size on the server!.

Posted on 2004-08-09
20
5,678 Views
Last Modified: 2008-03-03
Is threre any way to increase the default file size of 2MB to 20 MB, my web server admin won't allow changes in the php.ini on the server. Is threre any way I can allow my users upload around 20 MB.
-kani
0
Comment
Question by:str_kani
20 Comments
 
LVL 27

Expert Comment

by:Diablo84
ID: 11752646
Thank you :)

1) create file named ".htaccess" in root folder (unless one already exists)
2) add the following line

php_value upload_max_filesize "20M"
0
 
LVL 27

Expert Comment

by:Diablo84
ID: 11752652
that will change the local value (which will be applied to all scripts in your site) but wont affect the master value in the servers php.ini
0
 
LVL 27

Expert Comment

by:Diablo84
ID: 11752660
you could probably instead (if you only want to apply the setting to one script) add this line to the top of your script

ini_set("upload_max_filesize", "20M");
0
 
LVL 12

Author Comment

by:str_kani
ID: 11752661
My aim is to allow my site users to upload upto 20 MB files. My web master says he won't change settings in the php.ini on the server.

0
 
LVL 27

Expert Comment

by:Diablo84
ID: 11752667
thats ok, none of the above solutions require you do to so.
0
 
LVL 12

Author Comment

by:str_kani
ID: 11752690
Please tell me whether it can be done or not?
0
 
LVL 27

Expert Comment

by:Diablo84
ID: 11752707
yes... using one of the above solutions
0
 
LVL 27

Expert Comment

by:Diablo84
ID: 11752715
To recap:

option a)

create a .htaccess file in the root folder and add the line

php_value upload_max_filesize "20M"

or

option b)

add the following line to the top of your script

ini_set("upload_max_filesize", "20M");
0
 
LVL 12

Author Comment

by:str_kani
ID: 11752728
I created a file swe.htaccess
added this
php_value upload_max_filesize "20M"

placed this file in the root folder i.e. www.site.com

created another file...
<?php
echo phpinfo();
?>
still it shows 2M for the max file upload
0
 
LVL 27

Accepted Solution

by:
Diablo84 earned 50 total points
ID: 11752744
should be

.htaccess

no prefix

>> still it shows 2M for the max file upload

the master value will display as 2M and the local value (to the right of it) should display as 20M
0
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 
LVL 12

Author Comment

by:str_kani
ID: 11752780
I see that eactly you said... Actually what are they master and local. Could you Please explain that in a few line.
0
 
LVL 27

Expert Comment

by:Diablo84
ID: 11752785
to the left of it rather
0
 
LVL 27

Expert Comment

by:Diablo84
ID: 11752795
master values are those set in the php.ini basically

local values are those changed using a .htaccess file or the ini_set function which only apply to one user and do not affect master settings
0
 
LVL 12

Author Comment

by:str_kani
ID: 11752892
I tried to upload a zip of 3.9 MB the browser silently executed, but the file is not there in the position it should be. i.e the code is executed but the file hasn't uploeaded !
0
 
LVL 27

Expert Comment

by:Diablo84
ID: 11752944
Thats a whole new question and could be any number of things

error in code, error with folder permission etc
0
 
LVL 27

Expert Comment

by:Diablo84
ID: 11753022
check for obvious errors in your code and check you are using the correct syntax

and make sure you check that the folder you are uploading to has the permission set as 666 (or 777 for full access)
0
 
LVL 9

Expert Comment

by:waygood
ID: 11753290
I know this doesnt affect what your having trouble with at the moment.
But there is also a timeout in php and apache, it may be a good idea to increase these aswell.
0
 
LVL 12

Author Comment

by:str_kani
ID: 11753637
I am getting this warning.....

Warning: set_time_limit(): Cannot set time limit in safe mode in

How to solve this.?
0
 
LVL 18

Expert Comment

by:arantius
ID: 11754639
You can't.  That's a setting your web host controls.
0
 
LVL 27

Expert Comment

by:Diablo84
ID: 11756195
for general local settings using ini_set please refer to the manual online @ http://www.php.net/manual/en/function.ini-set.php
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Consider the following scenario: You are working on a website and make something great - something that lets the server work with information submitted by your users. This could be anything, from a simple guestbook to a e-Money solution. But what…
These days socially coordinated efforts have turned into a critical requirement for enterprises.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to count occurrences of each item in an array.

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now