LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 12-25-2003, 07:29 PM   #1
J_Szucs
Senior Member
 
Registered: Nov 2001
Location: Budapest, Hungary
Distribution: SuSE 6.4-11.3, Dsl linux, FreeBSD 4.3-6.2, Mandrake 8.2, Redhat, UHU, Debian Etch
Posts: 1,126

Rep: Reputation: 58
PHP: how to send a file?


I want that my users can download quarantined files (having arrived as mail attachment) on their own responsibilities from the mailserver.

To achieve this, I want to offer them a webpage (a form) where they can enter the filename; and submit it to a webserver, which returns them the file. Meanwhile I want to completely hide where the file is served from, i.e. there should not be any actual URL showing the location of the file.

I want to do this with PHP. I never did such thing, so I do not know how to get such request served by a PHP script (Maybe redirection? But I think that would inevitably reveal the URL...).

Could you give me a hint how to do this?

Last edited by J_Szucs; 12-25-2003 at 07:32 PM.
 
Old 12-25-2003, 09:53 PM   #2
fr0zen
Member
 
Registered: Nov 2003
Location: 127.0.0.1
Distribution: xubuntu
Posts: 217

Rep: Reputation: 30
What you need to do is look at the header() function and set the content type to something like "application\octet" and force the web browser to prompt a save dialog. Then, after setting the correct header sequence (I recommend reading www.php.net for information on the header() function), you simply echo out the file's data. Of course this requires you to read the file in. Function fread(), fopen, and fclose() may be of interest here.
 
Old 12-27-2003, 01:51 AM   #3
doofsmack
LQ Newbie
 
Registered: Dec 2003
Posts: 2

Rep: Reputation: 0
Or, if it's any easier, set the header, then just echo(file_get_contents($filename));
 
Old 12-27-2003, 10:04 PM   #4
J_Szucs
Senior Member
 
Registered: Nov 2001
Location: Budapest, Hungary
Distribution: SuSE 6.4-11.3, Dsl linux, FreeBSD 4.3-6.2, Mandrake 8.2, Redhat, UHU, Debian Etch
Posts: 1,126

Original Poster
Rep: Reputation: 58
Thanks for the tips; they worked!
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Send SMS via PHP? Swift&Smart Linux - Software 3 04-20-2008 06:45 PM
PHP : Send Data To Printer joseph Programming 1 04-07-2005 04:29 PM
Send errors via PHP RodimusProblem Programming 1 02-07-2005 09:37 AM
sendmail won't send from shell or php script dmedici Linux - Software 2 08-24-2004 03:15 PM
send mail via PHP from website on apache. not working mdkelly069 Linux - Software 0 02-25-2004 12:15 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 08:24 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration