RSS

Category Archives: PHP

Change title from node add form in Drupal

Changing title from node add/edit form in Drupal is pretty simple. You can do that with Drupal hooks from your custom module. Here is the simplest way to do that

function mymodule_form_alter(&$form, $form_state, $form_id) {
if($form_id == ‘mynodetype_node_form’){
if($form[‘nid’][‘#value’]){
drupal_set_title(t(“Edit My new title”));
}
else{
drupal_set_title(‘My new title’);
}
}
}

Advertisements
 
Leave a comment

Posted by on August 12, 2012 in Drupal, PHP, Uncategorized

 

Increase upload filesize in PHP from applicatoin

PHP calculates and displays the maximum file size that you can set based upon two PHP settings: ‘post_max_size’ and ‘upload_max_filesize’. Since ‘post_max_size’ is the limit for all the content of your post, many people choose ‘post_max_size’ to be a multiple of ‘upload_max_filesize’ to allow multiple files to be uploaded, but this is not essential. The upload module limits the size of a single attachment to be less than either post_max_size, or upload_max_filesize, whichever is smaller. The default PHP values are 2 MB for upload_max_filesize, and 8 MB for post_max_size.

To increase maximum upload limit we need to change into PHP.ini file. Maximum file upload size that you can set based upon two PHP settings: ‘post_max_size’ and ‘upload_max_filesize’. Since ‘post_max_size’ is the limit for all the content of your post, many people choose ‘post_max_size’ to be a multiple of ‘upload_max_filesize’ to allow multiple files to be uploaded, but this is not essential. The upload module limits the size of a single attachment to be less than either post_max_size, or upload_max_filesize, whichever is smaller. The default PHP values are 2 MB for upload_max_filesize, and 8 MB for post_max_size.
But we don’t have access into PHP.ini file while we are using a shared hostings. Still you can increase maximum upload file size from your application level. There is two way to do that. One is using PHP code and another is by .htaccess file.

Using .htaccess

Add the below to your .htaccess file in your root directory.

php_value upload_max_filesize 10M
php_value post_max_size 10M

By PHP code

Add following codes into your settings.php file

• ini_set(‘upload_max_filesize’, ’10M’);
• ini_set(‘ post_max_size’, ’10M’);

I will prefer to use .htaccess file to increase upload file size. Also you need to increase maximum executoin time for last files upload

php_value max_execution_time 300 #(default in ms)

The PHP documentation states that the memory_limit setting also affects file uploading. Generally speaking, memory_limit should be larger than post_max_size. If this is an issue, see the page on how to Increase memory available to PHP (3 methods)

 
Leave a comment

Posted by on December 28, 2010 in PHP

 

Tags: , ,