This article shares the specific codes for the generation and download of php QR code for your reference. The specific content is as follows
<?php //Introduce phpqrcode library filedefine('IN_ECS', true); require(dirname(__FILE__) . '/includes/'); include('includes/'); // QR code data$data = ''; $filename = 'shopEwm/'.''; //down_file('',BASE_PATH); setShopEwm($data,$filename); //Generate QR code picturesfunction setShopEwm($data,$filename){ // Error correction level: L, M, Q, H $errorCorrectionLevel = 'L'; // Point size: 1 to 10 $matrixPointSize = 4; //Create a QR code file QRcode::png($data, $filename, $errorCorrectionLevel, $matrixPointSize, 2); //Enter the QR code to the browser //QRcode::png($data); } //Download QR code picturefunction down_file($file_name){ $file_sub_dir = str_replace('\\','/',realpath(dirname(__FILE__).'/'))."/shopEwm/"; //Reason: PHP file function is relatively old and requires Chinese transcoding gb2312 $file_name=iconv("utf-8","gb2312",$file_name); //Absolute path $file_path=$file_sub_dir.$file_name; //1.Open the file if(!file_exists($file_path)){ echo "The file does not exist!"; return ; } $fp=fopen($file_path,"r"); //2. Process the file //Get the size of the downloaded file $file_size=filesize($file_path); /* if($file_size>30){ echo "<script language='javascript'>('too large')</script>"; return ; } */ //Returned file header("Content-type: application/octet-stream"); //Return according to byte size header("Accept-Ranges: bytes"); //Return file size header("Accept-Length: $file_size"); //The pop-up dialog box of the client here, the corresponding file name header("Content-Disposition: attachment; filename=".$file_name); //Release data to the client $buffer=1024; //For the sake of download security, we'd better make a file byte read counter $file_count=0; //This sentence is used to determine whether the file is over or not while(!feof($fp) && ($file_size-$file_count>0) ){ $file_data=fread($fp,$buffer); // Statistics how many bytes have been read $file_count+=$buffer; //Send some data back to the browser; echo $file_data; } //Close the file fclose($fp); }
The above is all the content of this article. I hope it will be helpful to everyone's study and I hope everyone will support me more.