Showing posts with label php. Show all posts
Showing posts with label php. Show all posts

Thursday, May 13, 2010

Php- File upload limit changing using htaccess/php.ini

FASTCGI  / APACHE - Changing PHP File upload limit 
Php default maximum upload limit is 8 MB. You can change the default settings by changing the server settings using .htaccess file or custom php5.ini file in the case of godaddy hosting.   
First thing you have to find out is what your server API is?
print out php info of your hosted server.



See the  Server API value.
If  the Server API is apache You can do the following


1) Create a .htaccess file in the root folder of web server.
2) Put the following code in side the .htaccess file and save it.
php_value upload_max_filesize 20M
php_value post_max_size 20M
php_value max_execution_time 200
php_value max_input_time 200

 This will work in godaddy hosting.

If your Server API is CGI/FASTCGI do the follwing . 

create a php5.ini file and write in it

upload_max_filesize = 100M
post_max_size = 100M
output_buffering = on
max_execution_time = 1000
max_input_time = 1000
memory_limit = 64M

And upload it to your websites root folder.
Check the phpinfo and you can see the changes if it worked.Do not forget to put the file name php5.ini.

Thursday, May 6, 2010

Php-codeigniter creating thumbnails

I have created a library function


function image_resize($data)
{
$this->CI =& get_instance();
$error="";
$config['image_library'] = 'gd2';
$config['source_image'] = $data['source_image'];
$config['new_image']= $data['new_image'];
$config['create_thumb'] =$data['create_thumb'];
$config['thumb_marker'] = $data['thumb_marker'];

$config['maintain_ratio'] = TRUE;
$config['width'] = $data['width'];
$config['height'] = $data['height'];

$this->CI->load->library('image_lib');
$this->CI->image_lib->clear();
$this->CI->image_lib->initialize($config);
if ( ! $this->CI->image_lib->resize())
{
$error= $this->CI->image_lib->display_errors();
}

Thursday, January 22, 2009

Php - how to verify email address entered by user

Php - how to verify email address entered by user

Call the function like this check_email("INFO@google.co.uk"); to do server email validation using PHP

By calling this, function validate the email against the regular expression

<?php
function check_email($mail_address) {
    $pattern = "/^[\w-]+(\.[\w-]+)*@";
    $pattern .= "([0-9a-z][0-9a-z-]*[0-9a-z]\.)+([a-z]{2,4})$/i";
    if (preg_match($pattern, $mail_address)) {
        $parts = explode("@", $mail_address);
        if (checkdnsrr($parts[1], "MX")){
            echo "The e-mail address is valid.";
            // return true;
        } else {
            echo "The e-mail host is not valid.";
            // return false;
        }
    } else {
        echo "The e-mail address contains invalid charcters.";
        // return false;
    }
}
check_email("INFO@google.co.uk");
?>