Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/229.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 在新窗口或选项卡中打开下载文件_Php_Joomla_Download_Joomla2.5_Meta Tags - Fatal编程技术网

Php 在新窗口或选项卡中打开下载文件

Php 在新窗口或选项卡中打开下载文件,php,joomla,download,joomla2.5,meta-tags,Php,Joomla,Download,Joomla2.5,Meta Tags,我正在做joomla组件编程。我需要在“新建”选项卡中打开下载文件。文件下载的代码是: <meta http-equiv="Refresh" content="3;URL=http://localhost/joomla/images/uploads/<?php echo $filee; ?> " > 在新窗口或选项卡中打开的唯一方法是删除重定向,并使用target=“\u blank”在感谢页面上添加指向文件的链接。经过多次搜索,我实现了在重定向请求到其他页面后在新窗口

我正在做joomla组件编程。我需要在“新建”选项卡中打开下载文件。文件下载的代码是:

<meta http-equiv="Refresh" content="3;URL=http://localhost/joomla/images/uploads/<?php echo $filee; ?> " >

在新窗口或选项卡中打开的唯一方法是删除重定向,并使用target=“\u blank”在感谢页面上添加指向文件的链接。

经过多次搜索,我实现了在重定向请求到其他页面后在新窗口中下载pdf文件的想法,共分四步-

1). Session::flash('myfileNameThatStoredInDb',  $orders->order_invoice);
2) 。使用以下代码在控制器中创建函数

public function pdfDownload($image_url){

        header('Content-Type: application/octet-stream');
        header("Content-Transfer-Encoding: Binary");
        header("Content-disposition: attachment; filename=\"" . basename($image_url) . "\"");
        readfile(\Url('storage').'/invoice'.'/'.$image_url); 
    }
3) 。为上述方法创建路由

Route::get('/pdfdownload/{url}',"OrderController@pdfDownload");
4) 。检查会话并在html文件标记中获取其值,并将其附加到控制器的方法路径

@if(Session::has('download.in.the.next.request'))    
        <meta http-equiv="refresh" content="5; url={{ asset('pdfdownload/'.Session::get('download.in.the.next.request')) }}">
    @endif
@if(Session::has('download.in.the.next.request'))
@恩迪夫
注意->这段代码在Laravel中工作得很好,我的目的只是想给大家一个想法。
感谢Joomla,我不会用meta标签下载文件。下载是通过表单还是按钮生成的?@Lodder:是的,先生。用户只有在填写表单后才能下载任何文件。我使用if条件来检查表单是否提交。然后,我在里面写了一些感谢信息和上面的下载元代码。表单提交后,将用户重定向到下载文件,不要使用元标记我使用此代码sir echo’window.open(“>”;使用此代码时是否有任何pblm?对我来说效果很好。谢谢您的回复,先生。但是我需要启动自动显示消息的下载。我如何做到这一点?您上面评论中的javascript是唯一的方法。