• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Codeigniter and php.ini problems in 1and1

#1
[eluser]thewiredman[/eluser]
Hello there,
I'm having a hard time to upload multiple files with Codeigniter in 1and1 hosting due to the directives in the php.ini
According to 1and1 FAQ you can create a php.ini and change the directives in any directory you want.

After I've uploaded a php.ini file to my root directory:
Code:
php_value upload_max_filesize "32M"
php_value post_max_size "34M"
php_value max_execution_time "600"
php_value max_input_time "600"

I still can't upload a file bigger than 20Mb which is the maximum size set by the hosting ,I've passed a variable with the ini_get values from my controller

Code:
function myaccount()
    {
            $data['title'] = " Accounts ";
            $data['state'] = " normal ";
            $data['php_values'] = ini_get("post_max_size") ." - " ini_get("upload_max_filesize");
            $this->load->view("myaccounts",$data);
    
    }

to my view and show them in the browser,
Code:
<?php echo $php_values;?>
but that variable returns the original configuration of the php.ini.

However if I run a standalone php file asking for the same information, I get the updated values I uploaded in my php.ini in the root directory.

Is there something I'm missing with codeigniter and its configuration?

Thanks for your help.

#2
[eluser]Sumon[/eluser]
Increase file upload size in PHP

In web technology file is most vital factors. Files like image are using last decade. Now time comes for audio and video. Peoples are not happy with only images. More exciting with audio and video what are more realistic presenter for any web site. As a developer i found difficulties while upload audio and video files. Image, audio and video files are same. I mean the upload process. All treat just as files. For images i don't get any problem because images are small in size normally. About audio and video these file formats are number of times greater in size then images. So i fall in problem.

There are two considerable factors for upload any file. These are
1. Execution time
3. File Size.

Your script must need to execute until the file is uploaded completely. And offcourse your server alow your expected upload file size. Php have default configuration for both issue. Execution time is set by default 60 seconds. And allowed maximum file size is up to 2MB. Now what shall you do for a audio or video file. Your internet connection might slow and need more execution time then default. Again you may need more file size to be allowed then 2MB. The question is how??

To increase your execution time write a single line of code at the beginning of your script. here it is:
set_time_limit(0);
?>

Now the big issue. Have to increase maximum file size as you need. One solution like:
ini_set("upload_max_filesize",30);
?>
For view current maximum allowed size (before and after change) use echo like:
echo ini_get("upload_max_filesize");
?>

Now the most critical one. Though almost all server allow set_time_limit(0) but Most of the server doesn't allow ini_set("upload_max_filesize",30). I find one more alternatives. You can edit the maximum size by using .htaccess. Means create a file named .htaccess write the following code in that file. Now upload it at the same path where your source file is. Now run your script and test with echo ini_get("upload_max_filesize");

.htaccess file code:

php_value upload_max_filesize "25M"

Enjoy your coding....... If you get any more solution please let me know. I am most novice one so i don't know much but like to learn.

#3
[eluser]thewiredman[/eluser]
Thanks for the reply Sumon, but unfortunately both solutions addressed in the blog aren't suitable in this case.

the first one that would be set the values in the controller :
Code:
function myaccount()    {
    ini_set("post_max_size",32000000);
    ini_set("upload_max_filesize",32000000);
}
Doesn't work. I checked the values in the view but they haven't changed, also i tried to upload a file but the server never uploaded the file.

On the other hand,the second solution, since it's a 1and1 hosting, and php5 is running as cgi, i can only upload a php.ini file to change the directives. So i can't add those values to the .htaccess file, well anyway I did it, but i started getting a 500 internal error from the server and also the values of the directives didn't change.
faq.1and1.com/scripting_languages_supported/php/14.html

So right now, I know that changing the php.ini works because a standalone php file (outside ci framework) shows the updated values. But I need my view file be able to work because it's where I'm going to upload the files.

So I'm not sure where to look or change in the ci framework so it recognizes the values I set up in that php.ini.

Any help is appreciated.

#4
[eluser]Sumon[/eluser]
did you tried with
Code:
You can edit the maximum size by using .htaccess. Means create a file named .htaccess write the following code in that file. Now upload it at the same path where your source file is. Now run your script and test with echo ini_get("upload_max_filesize");

.htaccess file code

php_value upload_max_filesize "500M"

#5
[eluser]thewiredman[/eluser]
Thanks for the reply sumon,

Well yeah I tried the .htaccess, but it doesn't change the value.

I'm looking how can I make Codeigniter classes (controller and views) aware of the changes in the php.ini I uploaded.
Since a simple php is recognizing the changes of the values. But I don't know why my view classes are not getting the new values.

Any ideas?

#6
[eluser]Sumon[/eluser]
Yes i found the solution. The location of .htaccess is your root. more specific the place where you place index.php of CI.
.htaccess have only single line code
Code:
php_value upload_max_filesize "25M"

if you already have .htaccess file in your rote then append this line at bottom.

Here is my code by which we can catch the changed value
Code:
function TestValueChangedByHtaccess()
{
  echo ini_get("upload_max_filesize");
}
I hope it work for you Smile

#7
[eluser]Unknown[/eluser]
create the php.ini in root directory of 1and1, and add:

upload_max_filesize = 35M;
post_max_size = 35M;


hope that helps





----------------
http://www.codejibe.com/


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.