在页面中当我输入代码时会自动创建一个PDF文件,同时在另一页面(.php)上显示。我不想在按下按钮时,PDF文件会在另一页面上显示,只想下载而不显示。请问有什么方法?
Button样式:https://i.stack.imgur.com/B93l1.png
<div class="form-group" align="right">
<center><input type="submit" id="btn_rfc" value="Validar" target="_blank" class="btn btn-primary" autocomplete="off" style="background-color: #3155B9; font-size: 20px; border-radius: 30px;" /></center></div>
PDF文件(打开一个新页面来显示它)
<?php
session_start();
if (isset($_SESSION['login'])) {
}else{
header("Location: ../../index.php");
}
require '../lib/nusoap.php';
$cliente = new nusoap_client('.....php');
require '../clases/conexion.php';
$mysql = new Conexion;
$mysql->conectar();
$mysql->SeleccionarDB("db");
$colsult = "select rfc from businesses where subdomain='".$_SESSION['login']."'";
$mysql->GetExecuteSql($colsult);
foreach ($mysql->result as $empre) {
$rfcEmpre = $empre['rfc'];
}
mysql_close($mysql->conexion);
$param = array('rfc' => $rfcEmpre);
$consult = $client->call('List',$param);
..
发布于 2018-07-20 17:29:12
你可以尝试将该按钮装入href标记中并链接到要下载的pdf。
<!DOCTYPE html>
<html>
<body>
<p>Click on the w3schools logo to download the image:<p>
<a href="/images/myw3schoolsimage.jpg" download>
<img border="0" src="/images/myw3schoolsimage.jpg" alt="W3Schools" width="104" height="142">
</a>
<p><b>Note:</b> The download attribute is not supported in Edge version 12, IE, Safari 10 (and earlier), or Opera version 12 (and earlier).</p>
</body>
</html>
如果你想下载的文件还没有创建(因为你在单击的同时创建了该文件)。我不知道你如何处理pdf的创建,所以抱歉我不能对此有所帮助。
https://stackoverflow.com/questions/-100005609
复制相似问题