这是我的上传
try {
$xmlWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, 'Word2007');
$xmlWriter -> save($path.$file);
}finally{
$fileup = file_get_contents($path.$file);
$upload = base64_encode($fileup);
$pdo = new PDO("mysql:host=localhost;dbname=db", "root", "Password");
$statement = $pdo->prepare("insert into upload_file(file_name,C_name)
values(?,?)");
$statement->bindParam(1,$upload);
$statement->bindParam(2,$name);
$statement->execute();
}
here's my download
$files = mysqli_query($conn,"SELECT*FROM upload_file WHERE C_name = '$name';");
$result = mysqli_fetch_assoc($files);
$con = $result['file_name'];
$content = base64_decode($con);
$filenamed = $result['C_name'];
header("Content-Disposition: attachment; filename=\"$filenamed\"");
header('ContentType:application/vnd.openxmlformatsofficedocument.wordprocessingml.document');
print $content;
exit;