Posts

How to upload a file in php with php validation of extension?

Simply copy and paste this code on your page And your input file name will be uploadedfile Like <input type="file" name="uploadedfile" /> and on submit of this page you will add this code $youruniqueid could be anything like userid or projected on the basis of this it will create folder for image upload $projId=$youruniqueid;    if(!empty($_FILES['uploadedfile']['name'])){     $imgExtension = array("jpg","jpe","jpeg","gif","png","GIF","JPG","JPEG","txt","pdf","PDF","docx","xlsx","pptx","pptm","doc","dot","xls","ppt");         $image_name = pathinfo($_FILES['uploadedfile']['name']);     $extension = strtolower($image_name['extension']);         if(in_array($extension,$imgExtension)){             $file_name = $_FILES['uplo

How to make a download link for download file in php

How to make a download link for download file in php or create a download link for download file in php? so here is the code and add base url according to your need   Create a php file download.php and paste this code in you php file $name = $_REQUEST['name']; // The file path where the file exists $filepath = 'http://www.site.com/files/'.$name; header("Pragma: public"); header("Expires: 0"); header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); //setting content type of page header("Content-Type: application/force-download"); header("Content-Disposition: attachment; filename=".basename($filepath )); header("Content-Description: File Transfer"); //Read File it will start downloading @readfile($filepath); Now add this link in your file on your anchor tag like <a href=" http://www.site.com/download.php?name=file.png " >download link</a>

How to get date from a timestamp in mysql?

Image
How to get date from a timestamp in mysql? simple you can use FROM_UNIXTIME function and pass the parameter. my table name is  messages like this: SELECT FROM_UNIXTIME(`created`,'%Y-%m-%d') as date FROM `messages`

How to create thumb image of uploaded image in php?

Simply copy and paste this code in your page and call generate_thumbimage_thumbnail() somthing like that $path  = 'uploadediamgepath/myimage.png'; $save_path2  = 'project_image_thumb/thumb__myimage.png'; $iscopied2 = copy($path , $save_path2); if($iscopied2){ generate_image_thumbnail($path, $save_path2); } function generate_thumbimage_thumbnail($source_image_path, $thumbnail_image_path) { define('THUMBNAIL_IMAGE_MAX_WIDTH', 130); define('THUMBNAIL_IMAGE_MAX_HEIGHT', 130); list($source_image_width, $source_image_height, $source_image_type) = getimagesize($source_image_path); switch ($source_image_type) { case IMAGETYPE_GIF: $source_gd_image = imagecreatefromgif($source_image_path); break; case IMAGETYPE_JPEG: $source_gd_image = imagecreatefromjpeg($source_image_path); break; case IMAGETYPE_PNG: $source_gd_image = imagecreatefrompng($source_image_path); break; } if ($source_gd_imag

How to get second last array in php?

lets take an example like this is your array Array ( [0] => 14802 Stony Plain Rd NW [1] => Edmonton [2] => AB T5N 3S5 ) and you want to get second last array " Edmonton" then simple use this array like this end ( $array ); $z = prev ( $array ); this is effective and you can get second last array. :)

How to get all record of yesterday from table in mysql?

Image
How to get all record of yesterday from table in mysql? if you are looking for sql query which will return you all record of yesterday. So please take a look on this query and replace the content according to your table Let your table is like this: So your query will be like this select id from tbl_download  WHERE date(download_date) = ADDDATE(current_date,-1) Happy coding :)

How to change the content of button of comment section in drupal?

How to change the content of button of comment section in drupal? if you want to change the content of button of comment box section submit button so follow this path yoursite/modules/comment and open this file  comment.module and search the keyword in this page  $form['submit'] = array('#type' => 'submit', '#value' => t('Save') replace the word Save to your desire word it will show on your comment section submit button.