php文件下载中的问题
我已经编写了下载文件所需的全部代码,但不知道为什么它不起作用,因为它正在下载我的download.php文件。请建议解决方案 索引文件php文件下载中的问题,php,Php,我已经编写了下载文件所需的全部代码,但不知道为什么它不起作用,因为它正在下载我的download.php文件。请建议解决方案 索引文件 <?php if(isset($_REQUEST['send'])){ $name = $_REQUEST['name']; $email = $_REQUEST['email_id']; $contact = $_REQUEST['contact_no']; if(empty
<?php
if(isset($_REQUEST['send'])){
$name = $_REQUEST['name'];
$email = $_REQUEST['email_id'];
$contact = $_REQUEST['contact_no'];
if(empty($name) || empty($contact) || empty($email)){
$err= "Please Fill the Fields.";
} else if(!preg_match("/^[(a-z)(A-Z) ]{2,50}$/", $name) || !preg_match("/^[(a-z)(0-9._-]+@[(a-z)(0-9)]+\.[(a-z).]{2,5}$/", $email) || !preg_match("/^[0-9]{10}$/", $contact)){
$err= "Please Enter Valid Details";
} else {
mail($email, "The Free Template From xyz", "Here is the link for the free template.
http://www.xyz.com/download.php?download_file=blue.zip ", "From: sales@xyz.com");
mail("sales@xyz.com", "Template Downloader Details", "Details:- \n Username: $name \n Email: $email \n Contact No: $contact" ,"From: $email");
$err= "The Download link has been sent to your E-mail ID.";
}
}
?>
下载文件
<?php
if(isset($_REQUEST['download_file'])){
$path = $_SERVER['DOCUMENT_ROOT']."/templatefile/";
$fullPath = $path.$_GET['download_file'];
$path_parts = pathinfo($fullPath);
header("Content-type: application/zip");
header("Content-Dispostion: attachment; filename=\"".$path_parts['basename']."\"");
readfile($fullPath);
}
header("Location: free-template.html");
?>
您是否在服务器上运行此脚本?我认为您不能在下载文件的同时执行位置:
重定向。所有header()
调用都必须在任何数据输出之前完成。我认为最后的header()
调用是这里的问题。试着把它取下来——它能用吗?不,它仍然不能用