Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function saveImage(){
- //magic...
- define('UPLOAD_DIR', '../webroot/img/');
- $base64string = str_replace('data:image/png;base64,', '', $base64string);
- $base64string = str_replace(' ', '+', $base64string);
- $data = base64_decode($base64string);
- $id = uniqid();
- $file = UPLOAD_DIR.$id.'.png';
- $success = file_put_contents($file, $data);
- }
- function getChart($uniqid= null){
- if($uniqid){
- $this->layout = null;
- header("Content-type: image/png");
- header("Content-Disposition:attachment;filename='".$uniqid.".png'");
- readfile('../webroot/img/'.$uniqid.'.png');
- exit;
- } else exit;
- }
- function getChart ($uniqid = null) {
- if (!$uniqid) exit;
- $this->layout = null;
- if (headers_sent()) throw new Exception('Headers sent.');
- while (ob_get_level() && ob_end_clean());
- if (ob_get_level()) throw new Exception('Buffering is still active.');
- header("Content-type: image/png");
- header("Content-Disposition:attachment;filename='".$uniqid.".png'");
- readfile('../webroot/img/'.$uniqid.'.png');
- exit;
- }
- header("Content-length: $file_size")
- header("Content-type: $file_type")
- header("Content-Disposition: attachment; filename=$file_name");
- // add ob_start() at the very top of your script
- function getChart($uniqid= null){
- echo strlen(ob_get_clean()); die(); // if it's not 0 then you are definetly echoing something
- if($uniqid){
- $this->layout = null;
- header("Content-type: image/png");
- header("Content-Disposition:attachment;filename='".$uniqid.".png'");
- readfile('../webroot/img/'.$uniqid.'.png');
- exit;
- } else exit;
- }
- function getChart($uniqid= null){
- if($uniqid){
- $image = $uniqid;
- header("Cache-Control: public");
- header("Content-Description: File Transfer");
- header("Content-Disposition: attachment; filename=" . $image);
- header("Content-Type: image/jpg");
- header("Content-Transfer-Encoding: binary");
- readfile($image);
- } else exit;
- }
- getChart("060620121945.jpg");
- function getChart($uniqid= null){
- if($uniqid){
- $mime_type = "image/png";
- $content = file_get_contents('../webroot/img/'.$uniqid.'.png');
- $base64 = base64_encode($content);
- return ('data:' . $mime_type . ';base64,' . $base64);
- } else exit;
- }
Add Comment
Please, Sign In to add comment