TalkPHP

TalkPHP (http://www.talkphp.com/forums.php)
-   Absolute Beginners (http://www.talkphp.com/absolute-beginners/)
-   -   PHP.ini change upload limit (http://www.talkphp.com/absolute-beginners/2696-php-ini-change-upload-limit.html)

killer-kurt 04-24-2008 01:34 PM

PHP.ini change upload limit
 
Hey guys,

I do appoligies if this is already here somewhere but i did take a look and found nothing. I want to change the upload limit in my PHP.ini on my server so i can upload bigger files on my forum. Could someone please tell me how to go about doing this. I can display the info for my php.ini but when it comes to PHP thats about it so everything will have to be explained.

Thanks in advance.

Village Idiot 04-24-2008 01:43 PM

There is no set size limit PHP sets, you can set the timeout limit so larger files dont time out.
PHP: set_time_limit - Manual

However, browsers have their own (extremely long) timeout limit. The only way to upload super large files is to use ajax.

killer-kurt 04-24-2008 01:48 PM

So when i try to upload a file and it returns the error

"The attachment’s file size is too large, the maximum upload size is 2 MB.
Please note this is set in php.ini and cannot be overridden."

This is because of a timeout limit?

Wildhoney 04-24-2008 01:49 PM

There are 2 INI variables that relate to the size of the uploads. Namely:

php Code:
ini_set('upload_max_filesize', '200M');
ini_set('post_max_size', '200M');

Village Idiot 04-24-2008 01:49 PM

Quote:

Originally Posted by Wildhoney (Post 13851)
There are 2 INI variables that relate to the size of the uploads. Namely:

php Code:
ini_set('upload_max_filesize', '200M');
ini_set('post_max_size', '200M');

Didn't know PHP had that.

Wildhoney 04-24-2008 01:52 PM

Quote:

Files are usually POSTed to the webserver in a format known as 'multipart/form-data'. The post_max_size sets the upper limit on the amount of data that a script can accept in this manner. Ideally this value should be larger than the value that you set for upload_max_filesize.

It's important to realize that upload_max_filesize is the sum of the sizes of all the files that you are uploading. post_max_size is the upload_max_filesize plus the sum of the lengths of all the other fields in the form plus any mime headers that the encoder might include. Since these fields are typically small you can often approximate the upload max size to the post max size.
Source: PHP File Upload Configuration

killer-kurt 04-24-2008 02:07 PM

Ok well i set it out like this in a page and loaded it:

Code:

<?
ini_set('upload_max_filesize', '300M');
ini_set('post_max_size', '300M');

 ?>

But it dident do nothing.

Is this correct??

Evulness 04-24-2008 02:15 PM

in your php.ini on line 552.
approx. halfway through the doc. you will see
Quote:

;;;;;;;;;;;;;;;;
; File Uploads ;
;;;;;;;;;;;;;;;;

; Whether to allow HTTP file uploads.
file_uploads = On

; Temporary directory for HTTP uploaded files (will use system default if not
; specified).
upload_tmp_dir = "c:/httpd/tmp"

; Maximum allowed size for uploaded files.
upload_max_filesize = 2M

change that?

killer-kurt 04-24-2008 02:19 PM

I dont have access to the php.ini on the server.

Evulness 04-24-2008 03:36 PM

then you either have to contact the system admin, and have them do it... or.. i don't know They probably have the ability to change ini settings disabled, hense why the ini code wildhoney gave didn't work...

Salathe 04-24-2008 04:18 PM

Depending on your server configuration, it might be possible to do one of the following:
  • Create a custom php.ini file for your website (or a sub-folder) with the necessary settings only.
  • Create a .htaccess file with php_value or php_flag declarations for the settings.

killer-kurt 04-24-2008 04:26 PM

Ok could you please guide me on how to do the first one (creating the custom php.ini in a sub folder) and attach it please. If that dont work then try the second?

sarmenhb 04-28-2008 05:13 AM

Quote:

Originally Posted by killer-kurt (Post 13866)
Ok could you please guide me on how to do the first one (creating the custom php.ini in a sub folder) and attach it please. If that dont work then try the second?

if your using a paid server look in the administration part of the place your logging in and look everywhere for php.ini if you find it view it then you can configure the upload settings.

if you cant find it anywhere you cant do anything else you have to contact the company or the administrator of the server to grant you access.

killer-kurt 04-28-2008 10:53 AM

I have looked for the php.ini its not there and have contacted my host and they will not allow anyone to change the file.

Salathe 04-28-2008 11:32 AM

Quote:

Originally Posted by killer-kurt (Post 13866)
Ok could you please guide me on how to do the first one (creating the custom php.ini in a sub folder) and attach it please. If that dont work then try the second?

Per-directory PHP.ini
Put a file named php.ini in your web root folder (often looks like /home/username/public_html) with the content:
INI Code:
upload_max_filesize = 300M
post_max_size = 300M

Per-directory .htaccess
Put a file named .htaccess in your web root folder:
HTACCESS Code:
php_value upload_max_filesize 300M
php_value post_max_size 300M

No guarantees but one or the other might work (or both, but don't use both!).


All times are GMT. The time now is 05:53 AM.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0