trigger a script?

 
Post new topic   Reply to topic    Aprelium Forum Index -> PHP
View previous topic :: View next topic  
Author Message
uod
-


Joined: 29 Apr 2006
Posts: 8
Location: PH

PostPosted: Sun May 04, 2008 7:31 am    Post subject: trigger a script? Reply with quote

is there a way to trigger a script, whenever a certain file from a directory is accessed?
Back to top View user's profile Send private message
Toasty
-


Joined: 21 Feb 2008
Posts: 296
Location: Chicago, IL

PostPosted: Sun May 04, 2008 5:19 pm    Post subject: Reply with quote

Accessed from another script? Or in general from anything?
_________________
Security Blog
Back to top View user's profile Send private message Visit poster's website
uod
-


Joined: 29 Apr 2006
Posts: 8
Location: PH

PostPosted: Mon May 05, 2008 1:18 pm    Post subject: Reply with quote

let just say i have a folder "mp3", and someone loaded it, or downloaded it, it should trigger a script.
Back to top View user's profile Send private message
rrinc
-


Joined: 24 Feb 2006
Posts: 725
Location: Arkansas, USA

PostPosted: Tue May 06, 2008 2:50 am    Post subject: Reply with quote

The best thing you can do is the reverse but equivalent of what you're wanting (have someone visit a script that then gives them the file or whatever).
_________________
-Blake | New Server :D
SaveTheInternet
Soy hispanohablante. Puedes contactarme por mensajes privados.
Back to top View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger
uod
-


Joined: 29 Apr 2006
Posts: 8
Location: PH

PostPosted: Tue May 06, 2008 11:25 am    Post subject: Reply with quote

i got your point, is there a a way to literally open the file? "Content-Disposition" is downloading a file, is there a way for example, *.txt file, should be handled by the browser by viewing its content
Back to top View user's profile Send private message
rrinc
-


Joined: 24 Feb 2006
Posts: 725
Location: Arkansas, USA

PostPosted: Tue May 06, 2008 11:19 pm    Post subject: Reply with quote

You would need to send the correct mime type in the header. .txt files are text/plain.

In PHP you would do something like:
Code:
<?php
header('Content-type: text/plain');
readfile('file.txt');
?>

_________________
-Blake | New Server :D
SaveTheInternet
Soy hispanohablante. Puedes contactarme por mensajes privados.
Back to top View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger
uod
-


Joined: 29 Apr 2006
Posts: 8
Location: PH

PostPosted: Wed May 07, 2008 11:27 am    Post subject: Reply with quote

thank you
Code:
header('Content-Type: audio/mpeg');
header('Content-Length: ' . filesize($file));
readfile($file);


i used this code to satisfy my needs
Back to top View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Aprelium Forum Index -> PHP All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB phpBB Group