จะทำ auto download file ติดปัญหานิดเดียว ช่วยหน่อยเถอะครับ TT

ตอบกระทู้

รูปแสดงอารมณ์
:icon_plusone: :like: :plusone: :gfb: :-D :) :( :-o 8O :? 8) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :wink: :!: :?: :idea: :arrow: :| :mrgreen: :angry: :baa: :biggrin:
รูปแสดงอารมณ์อื่นๆ

BBCode เปิด
[img] เปิด
[url] เปิด
[Smile icon] เปิด

กระทู้แนะนำ
   

มุมมองที่ขยายได้ กระทู้แนะนำ: จะทำ auto download file ติดปัญหานิดเดียว ช่วยหน่อยเถอะครับ TT

Re: จะทำ auto download file ติดปัญหานิดเดียว ช่วยหน่อยเถอะครับ TT

โดย tong_tong_tong » 29/06/2013 9:38 pm

อ้อ ครับ ต้องการให้เปิดหน้า homepage ค้างไว้ เพื่อ เก็บข้อมูลจาก web มาที่เครื่องลูก ตรวจสอบทุก8วิ แล้วสั่งให้เครื่องลูกเปิด เพื่อส่งค่าให้โปรแกรมอันอื่นๆ

Re: จะทำ auto download file ติดปัญหานิดเดียว ช่วยหน่อยเถอะครับ TT

โดย tsukasaz » 25/06/2013 9:34 am

robocon เขียน:

โค้ด: เลือกทั้งหมด

<META HTTP-EQUIV="Refresh" CONTENT="8;URL=auto.php">
ที่ว่าสั่งให้ refresh ทุกๆ 8 วินาทีตัวนี้ จะต้องเปิดเบราเซอร์ค้างเอาไว้นะครับ มันถึงจะทำงาน
ปิดเบราเซอร์ไปแล้วทุกอย่างก็หยุด

ถ้าจะทำเป็นพวก backup ไฟล์
กรณีเซิฟเวอร์เป็น IIS ลองใช้ Task Scheduler
หรือ
ถ้าเซิฟเวอร์เป็น Unix ลองใช้พวก Cron

เป็นตัวกำหนดเวลาในการทำงานดูครับ :-D
:like:

Re: จะทำ auto download file ติดปัญหานิดเดียว ช่วยหน่อยเถอะครับ TT

โดย robocon » 25/06/2013 8:43 am

โค้ด: เลือกทั้งหมด

<META HTTP-EQUIV="Refresh" CONTENT="8;URL=auto.php">
ที่ว่าสั่งให้ refresh ทุกๆ 8 วินาทีตัวนี้ จะต้องเปิดเบราเซอร์ค้างเอาไว้นะครับ มันถึงจะทำงาน
ปิดเบราเซอร์ไปแล้วทุกอย่างก็หยุด

ถ้าจะทำเป็นพวก backup ไฟล์
กรณีเซิฟเวอร์เป็น IIS ลองใช้ Task Scheduler
หรือ
ถ้าเซิฟเวอร์เป็น Unix ลองใช้พวก Cron

เป็นตัวกำหนดเวลาในการทำงานดูครับ :-D

จะทำ auto download file ติดปัญหานิดเดียว ช่วยหน่อยเถอะครับ TT

โดย tong_tong_tong » 22/06/2013 10:16 pm

ปรแกรมนี้ มันทำการ 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>'; ?>

ข้างบน