How to get Base64Image from input type file?

<input type="file" id="user_img_input" onchange="upload_user_img(this);" /> <img src="" id="img" /> <script> function setBase64Image(object, img_id) { if ( object.files && object.files[0] ) { var FR = new FileReader(); FR.onload = function(e) { $(img_id).attr("src", e.target.result); }; FR.readAsDataURL( object.files[0] ); } } function upload_user_img(inputObject) { setBase64Image(inputObject, '#img'); } </script> Live Demo:

Read More »

How to access Query String Values using Javascript?

Following function is very useful to easily access url paramters ( query string values). function getParameterByName(name, url) { if (!url) url = window.location.href; name = name.replace(/[\[\]]/g, "\\$&"); var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"), results = regex.exec(url); if (!results) return null; if (!results[2]) return ''; return decodeURIComponent(results[2].replace(/\+/g, " …

Read More »

Definition of the term “resource” in programming

Any object that you want users to be able to access via URI and perform CRUD (or some subset thereof) operations on can be thought of as a resource. Source Link

Read More »

Exclude one folder in htaccess protected directory

Just create an .htaccess file in the subdirectory with the content: Satisfy any  

Read More »

jQuery: How to open specific links in new tab having specific url?

Just put following code in your javascript file and It will pick all links globally from your website and will open them in a new tab. Don’t forget to replace url with your own website’s url. $(document).ready(function(){ $('a[href*="website.com"] ').click(function(e) { e.preventDefault(); window.open(this.href, '_blank'); return false; }); });  

Read More »

PHP: How to force to download remote file using php?

Following funcion can be used to force to download remote files via curl: $file = 'https://googledrive.com/host/0B_3oJnpnNoF9UjlkVUwtWE5CY0U/city.jpg'; download($file); function download($url) { set_time_limit(0); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); $r = curl_exec($ch); curl_close($ch); header('Expires: 0'); // no cache header('Cache-Control: must-revalidate, …

Read More »

WordPress: Best Plugin to improve your website speed in google

Today I wasted many hours to increase my website’s speed in google PageSpeed insights but I could not. I was in red color. But then I found following plugin that surprisingly increased my page speed. And now that website entered in Green on google: Plugin: GZip Ninja Speed URL: https://wordpress.org/plugins/gzip-ninja-speed-compression/ Further I …

Read More »

WordPress: Best Plugins to migrate website form one hosting to another hosting

Alright! Today I found an awesome, very useful and time saving plugin that can save your a lot of time if you are willing to migrate your wordpress website from one server to remote server. Just install this plugin: Welcome to WP Clone by WP Academy First install this plugin in …

Read More »

ffmpeg: how to convert .mov file to .mp4 format using php?

Following simple ffmpeg command can be used to convert video format from .mov to .mp4 exec("ffmpeg -i 1.MOV -vcodec copy -acodec copy out.mp4", $out);  

Read More »

PHP: how to display tweets on a webpage using php?

This simple tutorial will show how to display twitter tweets using custom php. Step 1: Download tweet-php from https://github.com/jnicol/tweet-php whereever you want. Step2: Add following code before the section where you want to display tweets: require_once('tweet-php/TweetPHP.php'); $TweetPHP = new TweetPHP(array( 'consumer_key' => 'xxxxxxxxxxxxxxxxxxxxx', 'consumer_secret' => 'xxxxxxxxxxxxxxxxxxxxx', 'access_token' => 'xxxxxxxxxxxxxxxxxxxxx', 'access_token_secret' => …

Read More »