Posts

Showing posts from November, 2015

How to take a screenshot or make a image of current screen using php and javascript with jquery or make a pdf file of current scrren

For create a image of current screen using javascript add below script into your file <script type="text/javascript"> function printDiv() {     jQuery('.year_box').remove(); // add your container id for capcture screen here i write "main_panel_body" for example     html2canvas([document.getElementById('main_panel_body')], {           onrendered: function(canvas)          {             var img = canvas.toDataURL();             jQuery('.overlay_box').show(); // calling ajax method for create image from binary data             $.post("save.php", {data: img}, function (file) {                 jQuery('.overlay_box').hide();             window.open("download.php?business_idsv="+business_id+"&limit="+limit+"&path="+ file,'_blank');});           }     });     jQuery('.year_box').show();         } </script> Here is my save.php file require_once("config.

How to use ajax without jquery with pure javascript

Here is a snippet code for ajax request.. var ajax = {}; ajax.x = function() {     if (typeof XMLHttpRequest !== 'undefined') {         return new XMLHttpRequest();     }     var versions = [         "MSXML2.XmlHttp.6.0",         "MSXML2.XmlHttp.5.0",          "MSXML2.XmlHttp.4.0",         "MSXML2.XmlHttp.3.0",          "MSXML2.XmlHttp.2.0",         "Microsoft.XmlHttp"     ];     var xhr;     for(var i = 0; i < versions.length; i++) {         try {             xhr = new ActiveXObject(versions[i]);             break;         } catch (e) {         }     }     return xhr; }; ajax.send = function(url, callback, method, data, sync) {     var x = ajax.x();     x.open(method, url, sync);     x.onreadystatechange = function() {         if (x.readyState == 4) {             callback(x.responseText)         }     };     if (method == 'POST') {         x.setRequestHeader('Content-type', 'application/x-www

How to upload image to another server like amazon etc using php CURL

For upload an image or any file to external server using php curl just refer below code. and change it according to your need. $profile_image_string = '';             if ( isset($_FILES['profile_image']) )             {                 $tmpfile = $_FILES['profile_image']['tmp_name'];                 $filename = basename($_FILES['profile_image']['name']);                 $filetype = $_FILES['profile_image']['type'];                 $org_image_string =curl_file_create($tmpfile,$filetype,$filename);             }     $ch = curl_init();                  $data = array('user_id'=>$_SESSION['student_id'],'firstname'=>$user_name,'gender'=>$gender,                             'user_profile_pic'=> $org_image_string);                  //echo $url = "server url for upload data";                  $header = array('Content-Type: multipart/form-data');