daily pastebin goal
64%
SHARE
TWEET

Untitled

a guest Jan 18th, 2019 51 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function saveImage(){
  2.     //magic...
  3.     define('UPLOAD_DIR', '../webroot/img/');
  4.     $base64string = str_replace('data:image/png;base64,', '', $base64string);
  5.     $base64string = str_replace(' ', '+', $base64string);
  6.     $data = base64_decode($base64string);
  7.     $id = uniqid();
  8.     $file = UPLOAD_DIR.$id.'.png';
  9.     $success = file_put_contents($file, $data);
  10. }
  11.    
  12. function getChart($uniqid= null){
  13.     if($uniqid){
  14.         $this->layout = null;
  15.         header("Content-type: image/png");
  16.         header("Content-Disposition:attachment;filename='".$uniqid.".png'");
  17.         readfile('../webroot/img/'.$uniqid.'.png');
  18.         exit;
  19.     } else exit;
  20. }
  21.    
  22. function getChart ($uniqid = null) {
  23.  
  24.     if (!$uniqid) exit;
  25.  
  26.     $this->layout = null;
  27.  
  28.     if (headers_sent()) throw new Exception('Headers sent.');
  29.     while (ob_get_level() && ob_end_clean());
  30.     if (ob_get_level()) throw new Exception('Buffering is still active.');
  31.  
  32.     header("Content-type: image/png");
  33.     header("Content-Disposition:attachment;filename='".$uniqid.".png'");
  34.     readfile('../webroot/img/'.$uniqid.'.png');
  35.  
  36.     exit;
  37. }
  38.    
  39. header("Content-length: $file_size")
  40.    
  41. header("Content-type: $file_type")
  42.    
  43. header("Content-Disposition: attachment; filename=$file_name");
  44.    
  45. // add ob_start() at the very top of your script
  46. function getChart($uniqid= null){
  47.     echo strlen(ob_get_clean()); die(); // if it's not 0 then you are definetly echoing something
  48.  
  49.     if($uniqid){
  50.         $this->layout = null;
  51.         header("Content-type: image/png");
  52.         header("Content-Disposition:attachment;filename='".$uniqid.".png'");
  53.         readfile('../webroot/img/'.$uniqid.'.png');
  54.         exit;
  55.     } else exit;
  56. }
  57.    
  58. function getChart($uniqid= null){
  59.     if($uniqid){
  60.  
  61.         $image = $uniqid;
  62.  
  63.         header("Cache-Control: public");
  64.         header("Content-Description: File Transfer");
  65.         header("Content-Disposition: attachment; filename=" . $image);
  66.         header("Content-Type: image/jpg");
  67.         header("Content-Transfer-Encoding: binary");
  68.  
  69.         readfile($image);
  70.  
  71.     } else exit;
  72. }
  73.  
  74. getChart("060620121945.jpg");
  75.    
  76. function getChart($uniqid= null){
  77.     if($uniqid){
  78.  
  79.         $mime_type = "image/png";
  80.         $content = file_get_contents('../webroot/img/'.$uniqid.'.png');
  81.         $base64   = base64_encode($content);
  82.         return ('data:' . $mime_type . ';base64,' . $base64);
  83.  
  84.     } else exit;
  85. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top