php 重定向下载,Codeigniter:下载文件并重定向

我在此页面上有一个表格http://www.obsia.com/products/thassos_wonder_brochure/

点击提交时,我希望它开始下载文件,并重定向到“谢谢”页面.但是我只能下载文件或重定向或加载“感谢下载”页面.

这是检查表格并提交的功能:

function thassos_wonder_brochure()

{

$this->load->helper('form');

$this->load->helper('email');

$this->load->library('email');

$this->load->library('form_validation');

//form validation

$this->form_validation->set_rules('firstname', 'First Name', 'required|max_length[32]');

$this->form_validation->set_rules('lastname', 'Last Name', 'required|max_length[32]');

$this->form_validation->set_rules('companyemail', 'Company Email', 'required|max_length[100]|valid_email|unique');

$this->load->model('brochure_model');

if ($this->form_validation->run() == FALSE)

{

// redisplay user form and repopulate fields

$this->load->view('/tw/thassos_wonder_brochure_view');

}

//display confirmation web page and send email

else

{

if($query = $this->brochure_model->addContact())

{

redirect('/thankyou/thassos_wonder_download'); (UPDATE)

}

}

}

下面是位于“谢谢”页面上的代码,其结尾是重定向到下载页面:(UPDATE)

<?php $this->load->view('header_view.php'); ?>

<?php $this->load->view('pmenu_view');?>

Thank you for Downloading

You have downloaded the brochure for ThassosWonder - for white stones specifically. You will also receive further information and link to the downloads in your email after you click on the confirmation link in your email.

Feel free to write to us, if you are unable <?php echo anchor('contact', 'to get desired finish from your white marble or stones')?>. You can upload a picture to get a thorough analysis from our Research Director.

<?php $this->load->view('footer_view');?>

这是我在下载页面上使用的代码.如何下载文件并重定向到“谢谢”页面.

$this->load->helper('download');

$name = 'ThassosWonder.pdf';

$data = file_get_contents("./downloads/brochures/Thassos_Wonder_Obsia.pdf"); // Read the file's contents - cannot use relative path. It will try to call the file from same directory (controller) as this file. In order for it get the contents from the root folder put a . in front of the relative path//

force_download($name, $data);

?>

任何帮助将不胜感激.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值