简体   繁体   English

自动下载特定文件夹中的csv文件

[英]To download a csv file in specific folder automatically

I want to download a csv file using a link automatically in a specified folder by running a cron job using PHP. 我想通过使用PHP运行cron作业,使用链接自动下载指定文件夹中的csv文件。

I tried the below code ,but it gets downloaded in download folder by default. 我尝试了以下代码,但默认情况下将其下载到下载文件夹中。

can any one show me the right way to do it.The code used is below. 谁能告诉我正确的方法。使用的代码如下。

$link="http://labcase.com/wrt/search.php?format=csv&sortby=reqnum|DESC&Search=non_closed_req&state[]=New&state[]=Pending%3A+Delivery&state[]=Pending%3A+Installation&state[]=On+Hold&state[]=Pending%3A+More+Info&state[]=Assigned&state[]=Working&state[]=Pending%3A+Approval&orgs[]=125&orgs[]=25&bldg[]=BGL04%2CBGL11%2CBGL12%2CBGL13%2CBGL14%2CBGL15%2CBGL16%2CBGL17%2CBGL20%2CBGL22%2CBGL25%2CBGL26%2CBGL43&business_unit=all";
header('Content-Disposition: attachment; filename=example.csv');
header("Content-Type: application/force-download");
header('Pragma: no-cache');
readfile($link);

You can use this: 您可以使用此:

file_put_contents("Tmpfile.zip", fopen("http://someurl/file.zip", 'r'));

Take a look here 在这里看看

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM