how to specify uploaded file size limit
Moderator: General Moderators
how to specify uploaded file size limit
Hello,
I am hosting some files from a hosting site. The limit for uploaded files is about 3MB. For some reason i want the uploaded file size limit to be more than that say 12MB. This i want it for only a single file which processes the uploaded files right? I am not pretty sure of the settings . In my local system i would have changed it in the php.ini configuration file. but i dont think i have access to the config file on the hosting server.
Question:
1. How do i specify the file uploaded size limit for a single page?
I am hosting some files from a hosting site. The limit for uploaded files is about 3MB. For some reason i want the uploaded file size limit to be more than that say 12MB. This i want it for only a single file which processes the uploaded files right? I am not pretty sure of the settings . In my local system i would have changed it in the php.ini configuration file. but i dont think i have access to the config file on the hosting server.
Question:
1. How do i specify the file uploaded size limit for a single page?
Re: how to specify uploaded file size limit
You'll want to use ini_set() to increase the upload_max_filesize and possibly post_max_size as well for that particular page.
http://us2.php.net/manual/en/function.ini-set.php
http://us2.php.net/manual/en/function.ini-set.php
Re: how to specify uploaded file size limit
tried the same but failed to get results
Got one more question.. Can i specify like this?
Q2:
There are two pages
page1. contains the form to upload the file
page2: processes the upload file
I believe i have to put the above code in page2. Please tell me if i am right?
Code: Select all
ini_set('upload_max_filesize',1300000000);
ini_set('post_max_size',2000000000);
Code: Select all
ini_set('upload_max_filesize','13M');
ini_set('post_max_size','20M');
There are two pages
page1. contains the form to upload the file
page2: processes the upload file
I believe i have to put the above code in page2. Please tell me if i am right?
Re: how to specify uploaded file size limit
Yes, this would go on the page processing the uploads:
Code: Select all
ini_set('upload_max_filesize','13M');
ini_set('post_max_size','20M');
Re: how to specify uploaded file size limit
I think this might help. I am using PHP 5.2.5 version
no results yet.
Firstly i thought i should give the actual values instead of giving as '13M' or so.
So i changed to the actual integer values like this.
Still no use
I echoed the
Code giving me 1 implying that it exceeded maximum size.
Have further researched into the php manuals for the ini_set() funciton.
http://us2.php.net/manual/en/ini.list.php
I got to know that PHP_IN_ALL implies can be changeable. but what does PHP_INI_PERDIR mean?
Sorry if its off topic but i failed to understand the meaning.
Googled out for a while regarding the same and found that it cannot be changed in ini_set() function for the versions higher than 5.1 or so.
Considering the option of using .htacess but not sure if even that works..
no results yet.
Firstly i thought i should give the actual values instead of giving as '13M' or so.
So i changed to the actual integer values like this.
Code: Select all
ini_set('upload_max_filesize',13631488);
ini_set('post_max_size',20971520);
I echoed the
Code: Select all
echo $_FILES['video']['error'];Have further researched into the php manuals for the ini_set() funciton.
http://us2.php.net/manual/en/ini.list.php
I got to know that PHP_IN_ALL implies can be changeable. but what does PHP_INI_PERDIR mean?
Sorry if its off topic but i failed to understand the meaning.
Googled out for a while regarding the same and found that it cannot be changed in ini_set() function for the versions higher than 5.1 or so.
Considering the option of using .htacess but not sure if even that works..
Re: how to specify uploaded file size limit
You can't change the limits inside the script. By the time the code gets executed the upload will already have happened.
Alter the php.ini file if you have access, otherwise putting
inside a .htaccess will do the job.
PHP_INI_PERDIR means using .htaccess and php_value like I just gave.
Alter the php.ini file if you have access, otherwise putting
Code: Select all
php_value upload_max_filesize 13M
php_value post_max_size 20MPHP_INI_PERDIR means using .htaccess and php_value like I just gave.
Re: how to specify uploaded file size limit
Here are a few things i did
1. Created a .htaccess file
2. Pasted the exact code as given.
3. Restarted the server
No results.
Is there any other OPTIONS i need to set for the htaccess file??
1. Created a .htaccess file
2. Pasted the exact code as given.
3. Restarted the server
No results.
Is there any other OPTIONS i need to set for the htaccess file??
Re: how to specify uploaded file size limit
The syntax for setting it in .htaccess is different. A few google searches and you should be able to find it.
Re: how to specify uploaded file size limit
I guess it depends on what "different" means.astions wrote:The syntax for setting it in .htaccess is different. A few google searches and you should be able to find it.
http://php.net/manual/en/configuration.changes.php
Re: how to specify uploaded file size limit
Finally got it.
In the httpd.conf file i had this
Code: Select all
<Directory "D:/Dev/Apache Software Foundation/Apache2.2/htdocs">
AllowOverride AuthConfig
</Directory>
That means it only checks for authentication purpose. Changed it to
AllowOverride Options AuthConfig
Restarted the server.
The .htaccess file looks like thisCode: Select all
php_value upload_max_filesize 13M
php_value post_max_size 20M
Have been
Thanks everyone.