Jump to content


php script that auto downloads txt file


5 replies to this topic

#1 HEki_

    Young Padawan

  • Members
  • Pip
  • 165 posts

Posted 28 March 2008 - 03:03 AM

Hi,

i was wondering if there is a way to make a program in php that autodownloads .txt file
from my server ...
So i write something in .txt file and upload it to my server. on my page i have a button "New messages" and when
a user clicks that button it downloads all the txt files in /new directory without needing to press the "save" or "ok" button in browser ...

so basicly a script that connects to my domain/new directory and downloads .txt files automaticly ...

best regards,
heki

#2 The Creator

    Young Padawan

  • Members
  • Pip
  • 115 posts
  • Gender:Male
  • Location:England
  • Interests:Computers, Music, Technology, Sport

Posted 28 March 2008 - 07:24 AM

From my knowledge the best way to download a file in php is using this code:

<?php
header('Content-disposition: attachment;');
header('Content-type: content type of file');
readfile('path to file here');
?>

That however shows a download window...

maybe this will help, i have not tried it myself but it seems more advanced than my little bit of code :biggrin:

http://www.zubrag.co...ts/download.php


To be honest i doubt you'll be able to make a user download a file without confirmation, and even if you can, their virus software might see it as an attack and stop it. I think you're best off using a different method, maybe using your database for example.

Hope that helps,

The Creator

#3 HEki_

    Young Padawan

  • Members
  • Pip
  • 165 posts

Posted 28 March 2008 - 09:06 AM

yeah, i get what u mean ...

so what would be the best way to get something to a group of people? RSS system, newsletter system? but it would have to be visible when the new news arrives ...

#4 The Creator

    Young Padawan

  • Members
  • Pip
  • 115 posts
  • Gender:Male
  • Location:England
  • Interests:Computers, Music, Technology, Sport

Posted 28 March 2008 - 10:34 AM

well i would personally go for a newsletter system but it depends. what kind of messages are you sending them? news? general? personal?

#5 HEki_

    Young Padawan

  • Members
  • Pip
  • 165 posts

Posted 28 March 2008 - 11:03 AM

yeah,
i will be sending general news ...

#6 The Creator

    Young Padawan

  • Members
  • Pip
  • 115 posts
  • Gender:Male
  • Location:England
  • Interests:Computers, Music, Technology, Sport

Posted 28 March 2008 - 11:32 AM

then i would either have a news page on your site with a list of the news that can be inserted and retrieved from your database. or the other option is to do a newsletter system. i would go with the news page :biggrin: there are tonnes of tuts on them if you don't know how to make them. ;)

good luck,

The Creator





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users