ปรแกรมนี้ มันทำการ download ไฟล์ swap.txt แบบ auto
โปรแกรมนี้ชื่อ autodown.php
code ข้างใน
Code (PHP)
01.<?php
02.
03.$export_file = "swap.txt";
04.ob_end_clean();
05.ini_set('zlib.output_compression','Off');
06.
07.header('Pragma: public');
08.header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); // Date in the past
09.header('Last-Modified: '.gmdate('D, d M Y H:i:s') . ' GMT');
10.header('Cache-Control: no-store, no-cache, must-revalidate'); // HTTP/1.1
11.header('Cache-Control: pre-check=0, post-check=0, max-age=0'); // HTTP/1.1
12.header ("Pragma: no-cache");
13.header("Expires: 0");
14.header('Content-Transfer-Encoding: none');
15.header('Content-Type: application/vnd.ms-excel;'); // This should work for IE & Opera
16.header("Content-type: application/x-msexcel"); // This should work for the rest
17.header('Content-Disposition: attachment; filename="'.basename($export_file).'"');
18.
19.?>
มันทำงานได้ดีมาก แ่ต่ผมต้องการให้มันทำงานอีกครั้ง ผมก็เพิ่มตรงนี้เข้าไป แต่มันไม่ยอมทำงานที่ ทุกๆ 8 วิตามที่ตั้งไว้ ผมต้องการให้มัน download ไฟล์นี้จาก server ทุกๆ 8 วิ ปรกติถ้าเรากดปุ่ม reload ที่ browser มันจะให้ download ให้ แต่พอเขียนโปรแกรมดังนี้ มันไม่ยอม
โปรแกรมนี้ชื่อ auto.php
code ข้างใน
Code (PHP)
01.<?php echo '<html><head><title>autosave setoutput.txt</title></head>';
02.echo '<META HTTP-EQUIV="Refresh" CONTENT="8;URL=auto.php">'; //สั่งให้ reload ทุก 8 วิ
03.
04.
05.
06.
07.$export_file = "swap.txt";
08.ob_end_clean();
09.ini_set('zlib.output_compression','Off');
10.
11.header('Pragma: public');
12.header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); // Date in the past
13.header('Last-Modified: '.gmdate('D, d M Y H:i:s') . ' GMT');
14.header('Cache-Control: no-store, no-cache, must-revalidate'); // HTTP/1.1
15.header('Cache-Control: pre-check=0, post-check=0, max-age=0'); // HTTP/1.1
16.header ("Pragma: no-cache");
17.header("Expires: 0");
18.header('Content-Transfer-Encoding: none');
19.header('Content-Type: application/vnd.ms-excel;'); // This should work for IE & Opera
20.header("Content-type: application/x-msexcel"); // This should work for the rest
21.header('Content-Disposition: attachment; filename="'.basename($export_file).'"');
22.
23.
24.
25.
26.echo '</body>';
27.echo '</html>'; ?>
จะทำ auto download file ติดปัญหานิดเดียว ช่วยหน่อยเถอะครับ TT
Moderators: mindphp, ผู้ดูแลกระดาน
-
- PHP Newbie
- Posts: 9
- Joined: 27/05/2013 5:12 pm
Re: จะทำ auto download file ติดปัญหานิดเดียว ช่วยหน่อยเถอะครับ TT
Code: Select all
<META HTTP-EQUIV="Refresh" CONTENT="8;URL=auto.php">
ปิดเบราเซอร์ไปแล้วทุกอย่างก็หยุด
ถ้าจะทำเป็นพวก backup ไฟล์
กรณีเซิฟเวอร์เป็น IIS ลองใช้ Task Scheduler
หรือ
ถ้าเซิฟเวอร์เป็น Unix ลองใช้พวก Cron
เป็นตัวกำหนดเวลาในการทำงานดูครับ

- tsukasaz
- PHP VIP Members
- Posts: 13067
- Joined: 18/04/2012 9:39 am
Re: จะทำ auto download file ติดปัญหานิดเดียว ช่วยหน่อยเถอะครับ TT
robocon wrote:ที่ว่าสั่งให้ refresh ทุกๆ 8 วินาทีตัวนี้ จะต้องเปิดเบราเซอร์ค้างเอาไว้นะครับ มันถึงจะทำงานCode: Select all
<META HTTP-EQUIV="Refresh" CONTENT="8;URL=auto.php">
ปิดเบราเซอร์ไปแล้วทุกอย่างก็หยุด
ถ้าจะทำเป็นพวก backup ไฟล์
กรณีเซิฟเวอร์เป็น IIS ลองใช้ Task Scheduler
หรือ
ถ้าเซิฟเวอร์เป็น Unix ลองใช้พวก Cron
เป็นตัวกำหนดเวลาในการทำงานดูครับ

The last bug isn't fixed until the last user is dead. (Sidney Markowitz, 1995)
Re: จะทำ auto download file ติดปัญหานิดเดียว ช่วยหน่อยเถอะครับ TT
อ้อ ครับ ต้องการให้เปิดหน้า homepage ค้างไว้ เพื่อ เก็บข้อมูลจาก web มาที่เครื่องลูก ตรวจสอบทุก8วิ แล้วสั่งให้เครื่องลูกเปิด เพื่อส่งค่าให้โปรแกรมอันอื่นๆ
-
- Similar Topics
- Replies
- Views
- Last post
-
-
แสดงชื่อไฟล์ที่เป็น non-US-ASCII บน File Download dialog box
by jataz2 » 03/06/2015 10:43 am » in Programming - C/C++ & java & Python - 0 Replies
- 500 Views
-
Last post by jataz2
03/06/2015 10:43 am
-
-
- 0 Replies
- 2540 Views
-
Last post by mindphp
23/06/2012 2:00 pm
-
-
[Extension phpBB3.1.1] File Download Extension บล็อคในการดาวโหลด
by จันนุสรณ์ ดีแก่ » 23/01/2019 11:58 am » in phpBB 3.1 Extension Review - 0 Replies
- 1230 Views
-
Last post by จันนุสรณ์ ดีแก่
23/01/2019 11:58 am
-
-
-
กด download แล้วไม่ไปหน้าที่เราจะทำ download ไฟล์
by eange08 » 13/01/2021 7:13 pm » in JavaScript & Jquery Ajax - 1 Replies
- 342 Views
-
Last post by eange08
14/01/2021 4:53 pm
-
-
- 0 Replies
- 576 Views
-
Last post by jamepiyawat
20/09/2019 3:50 pm
-
-
จะทำ image swap (Rollover) ใน TinyMCE ของ joomla3.4 ยังไงครับ
by toonytoony2004 » 04/10/2015 8:49 pm » in Joomla Development - 1 Replies
- 655 Views
-
Last post by tsukasaz
05/10/2015 8:49 am
-
-
-
ใครมีcode php แนะนำเกี่ยวกับ การ extract file pdf และ word เป็น text file บ้างคร
by beer_adisorn » 19/11/2011 11:25 am » in Programming - PHP - 4 Replies
- 2944 Views
-
Last post by beer_adisorn
22/11/2011 9:54 pm
-
Who is online
Users browsing this forum: Bing [Bot] and 11 guests