Welcome Guest, Not a member yet? Register   Sign In
Temporarily change max_size for file uploads
#1

[eluser]JoostV[/eluser]
Hi all,

I am looking for code to change maximum size for uploads on-the-fly. I would like to accept posting of video files up to 20MB by one special user. All other users will have to make do with the default php.ini settings.

The default settings are:
post_max_size = 8M
upload_max_filesize = 2M

I added this code to the constructor of my controller, but I still can't post files that exceed my .ini limits. Upload class returns error 'The uploaded file exceeds the maximum allowed size in your PHP configuration file.'.
Code:
$this->data['max_size'] = 20; // Set new upload size, in megabytes
$this->data['max_size'] *= 1024 *1024; // Convert to bytes

// Temporarily change max upload settings
ini_set('post_max_size', $this->data['max_size']);
ini_set('upload_max_filesize', $this->data['max_size']);

What am I doing wrong? Is it at all possible to temporarily change max upload size? I would rather not change php.ini settings.
#2

[eluser]xwero[/eluser]
You should work the other way around. Set the ini as high as the largest upload size and limit the users max size when uploading.
Code:
$config['max_size'] = ($user == 'vip')?20000:8000;
#3

[eluser]JoostV[/eluser]
I was afraid of that. Problem is that I already have 20 websites running on that server and I would hate to have to dive into their code to limit max sizes.
#4

[eluser]xwero[/eluser]
it's possible the problem is your max_input_time setting. I once had a similar problem and changing the max_input_time did the trick.

But i wonder don't you use max_size for your other sites for uploading a file?
#5

[eluser]JoostV[/eluser]
No, not on all of them. Some of these sites are fairly old, i.e. 2004.




Theme © iAndrew 2016 - Forum software by © MyBB