<br />
<b>Warning</b>: fread() expects parameter 1 to be resource, boolean given in <b>D:\phpStudy\WWW\lunhui_tp5\public\download.php</b> on line <b>12</b><br />
<br />
<b>Warning</b>: fclose() expects parameter 1 to be resource, boolean given in <b>D:\phpStudy\WWW\lunhui_tp5\public\download.php</b> on line <b>13</b><br />
很奇怪的事我修改一下标题的汉子就有时可以有时不行,考虑应该是编码问题,可是怎么修改呢?求大神指导。。。
DOWN.PHP
<?php
$filename = base64_decode($_GET['filename']);
var_dump($filename);
$fileinfo = pathinfo($filename);
$file=fopen($filename,"r");
header("Content-Type: application/octet-stream");
header("Accept-Ranges: bytes");
header("Accept-Length: ".filesize($filename));
header("Content-Disposition: attachment; filename=".$fileinfo['basename']);
ob_clean();
flush();
echo fread($file,filesize($filename));
fclose($file);
exit();TEMPLATE.PHP<?php
require_once 'vendor/autoload.php';
$data=$_POST;
$str =$data['sadate'];
$arr=explode('-', $str);
$document = new \PhpOffice\PhpWord\TemplateProcessor('word.docx');
$document->setValue('名称', $data['jname']);
include_once('./qrcode/phpqrcode.php');
$qrcode=$data['bianhao'];
$pic='./qrcode/pic/'.$data['bianhao'].'.png';
$errorCorrectionLevel = 'L';
$matrixPointSize = 4;
QRcode::png ( $qrcode, $pic, $errorCorrectionLevel, $matrixPointSize, 2 );
if(file_exists($pic))
{
$arrImagenes=array('src' => $pic,'swh'=>'100');
$document->setImg('Image', $arrImagenes);
}
$filename = './word/'.date('md').iconv("utf-8","gbk",$data['ajname']).'.docx';
$document->saveas($filename);
echo base64_encode($filename);
?> 最佳答案