<?php $error_codes = array( 0=>"There is no error, the file uploaded with success", 1=>"The uploaded file exceeds the upload_max_filesize directive in php.ini", 2=>"The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form", 3=>"The uploaded file was only partially uploaded", 4=>"No file was uploaded", 6=>"Missing a temporary folder", 7=>"Failed to write file to disk", 8=>"A PHP extension stopped the file upload" ); /* Posssible Usage */ if($_FILES["userfile"]["error"] > 0){ $code = $_FILES["userfile"]["error"]; echo $error_codes[$code]; } else{ //do the processing } ?>
Sunday, October 28, 2012
php file upload error messages in a php array
Hope this will be useful to someone, all the php file upload error codes and messages in an array.
Tuesday, October 23, 2012
How to change default timezone in Ubuntu command-line
In a Ubuntu / Debian based Linux system you can use the following command to run the timezone setup to change the default timezone
dpkg-reconfigure tzdata
Monday, October 22, 2012
High Swapping On Linode 512 - KeepAliveTimeout
I thought of sharing my experience on handling the high swapping issue I faced recently. There is nothing wrong with Linode service, its just my dumb Apache configurations.
Linode is a great hosting service but for a Linux administration newbie it can be a challenging place.
Swapping problem was a nightmare, I tried adding another 512MB to the Linode box and still it goes into full swap. Then I get to know about the Apache KeepAliveTimeout.
KeepAliveTimeout - Amount of time the server will wait for subsequent requests on a persistent connection.
Unfortunately for me the default value was 15 which is a super high value. After changing the value to 4 all was smooth again.
Swapping can occur for many reasons like bad scripting but KeepAliveTimeout value can be a main suspect :)
Linode is a great hosting service but for a Linux administration newbie it can be a challenging place.
Swapping problem was a nightmare, I tried adding another 512MB to the Linode box and still it goes into full swap. Then I get to know about the Apache KeepAliveTimeout.
KeepAliveTimeout - Amount of time the server will wait for subsequent requests on a persistent connection.
Unfortunately for me the default value was 15 which is a super high value. After changing the value to 4 all was smooth again.
Swapping can occur for many reasons like bad scripting but KeepAliveTimeout value can be a main suspect :)
Tuesday, October 16, 2012
How to check and fix Domain Canonicalization (www)
It's a common configuration in web servers to point both urls of www.example.com and example.com to same content. This is a bad practice in terms of SEO because they regarded as duplicate content. If you have access to the .htaccess and assuming your Apache server has mod_rewrite enabled, you can add following lines to redirect traffic and issue a 301 (Moved Permanently).
I prefer my site addresses without www
If you like to have your addresses with www use the following
If you have any sub domains like blog.example.com do not use the above code.
I prefer my site addresses without www
RewriteEngine On
RewriteCond %{HTTP_HOST} !^example.com [NC]
RewriteRule ^(.*)$ http://example.com/$1 [L,R=301]
If you like to have your addresses with www use the following
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www.example.com [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301]
If you have any sub domains like blog.example.com do not use the above code.
Tuesday, August 7, 2012
How to find MPM mode of Apache - Prefork or Worker
to find the Apache MPM mode you can simply run following command.
in Ubuntu u can try
in CentOS type of linux u can try
in Ubuntu u can try
apache2 -V
in CentOS type of linux u can try
httpd -V
Subscribe to:
Posts (Atom)