php1 Posted August 13, 2008 Share Posted August 13, 2008 Dear all, my php script is in the folder /var/www/html I have a wav file stored in "/var/www/play.wav". but when I make a link as below it is not working <a href="/var/www/paly.wav>play</a>. but if i store the file in /var/www/html which is my web path ie /var/www/html/paly.wav and give link as <a href="play.wav">play</a> it is working. I want to know is it possible to make a link like /var/www/paly.wav which is a physical absolute path(non-web path). Because my files are stored outside webpath and I want to display those wav files and play it. is there any methods to achieve this> thanks Link to comment https://forums.phpfreaks.com/topic/119449-is-it-possible-to-make-a-link-to-the-file-stored-in-a-physical-pathnon-web-pat/ Share on other sites More sharing options...
friedemann_bach Posted August 13, 2008 Share Posted August 13, 2008 If you want to display your wav files on the web, why not store them in a web path? If you want to link to your physical directory from the web, try setting up a script like 'play_wav.php': <?php $path = '/var/www/'; $filename = $_GET[name].'.wav'; passthru ($path.$filename) ?> and call that script with 'play_wav.php?name=something'. It will pass the file 'something.wav' (if it exists) to your installed player. Link to comment https://forums.phpfreaks.com/topic/119449-is-it-possible-to-make-a-link-to-the-file-stored-in-a-physical-pathnon-web-pat/#findComment-615354 Share on other sites More sharing options...
php1 Posted August 13, 2008 Author Share Posted August 13, 2008 thank u very much for your reply. But I did'nt get the output this is my play.html page <html> <head> </head> <body> <a href="play_wav.php?name=play.wav">play</a> </body> </html> this is play_wav.php <?php $path = "/tmp/recordings/"; $filename = $_GET['name']; passthru($path.$filename) ?> But i did'nt get any output like open or download file dialog box to hear the sound. Link to comment https://forums.phpfreaks.com/topic/119449-is-it-possible-to-make-a-link-to-the-file-stored-in-a-physical-pathnon-web-pat/#findComment-615375 Share on other sites More sharing options...
friedemann_bach Posted August 13, 2008 Share Posted August 13, 2008 Right. Check your path first: <?php $path = 'your_path/'; // !! better use an absolute path here $filename = $path.$_GET[name]; if (is_file($filename)) { passthru ($filename); echo 'Click <a href=".">here</a> to get back to the index.'; } else { echo $filename.': File not found.'; } ?> passthru() does not give any error message if the filename is wrong. Link to comment https://forums.phpfreaks.com/topic/119449-is-it-possible-to-make-a-link-to-the-file-stored-in-a-physical-pathnon-web-pat/#findComment-615381 Share on other sites More sharing options...
php1 Posted August 13, 2008 Author Share Posted August 13, 2008 my play.html file is: <html> <head> </head> <body> <a href="play_wav.php?name=play.wav">play</a> </body> </html> the play_wav.php is this: <?php $path = "/tmp/recordings/"; $filename = $path.$_GET['name']; echo $filename;echo "<br/>"; if (is_file($filename)) { passthru ($filename); echo 'Click <a href=".">here</a> to get back to the index.'; } else { echo $filename.': File not found.'; } ?> The output I got is: Click here to get back to the index. Link to comment https://forums.phpfreaks.com/topic/119449-is-it-possible-to-make-a-link-to-the-file-stored-in-a-physical-pathnon-web-pat/#findComment-615391 Share on other sites More sharing options...
php1 Posted August 13, 2008 Author Share Posted August 13, 2008 thank u for your reply.. But still that open-download dialog box is not coming Link to comment https://forums.phpfreaks.com/topic/119449-is-it-possible-to-make-a-link-to-the-file-stored-in-a-physical-pathnon-web-pat/#findComment-615392 Share on other sites More sharing options...
friedemann_bach Posted August 13, 2008 Share Posted August 13, 2008 An open-download dialog will probably not appear. It will usually open your standard media player directly. Did you try an absolute path? Link to comment https://forums.phpfreaks.com/topic/119449-is-it-possible-to-make-a-link-to-the-file-stored-in-a-physical-pathnon-web-pat/#findComment-615441 Share on other sites More sharing options...
php1 Posted August 14, 2008 Author Share Posted August 14, 2008 kk.. then how can we understand or the users get the feeling that something is playing on the background. I think that if it play using real timeplayer the the real time player window will open and from that we are able to understand that the file is playing. if using winamp then winamp window will open and play the song. but what I am getting is a blank page only. its is not opening any default players window. is it like that or I have to do code to see the default audio player window open Link to comment https://forums.phpfreaks.com/topic/119449-is-it-possible-to-make-a-link-to-the-file-stored-in-a-physical-pathnon-web-pat/#findComment-616336 Share on other sites More sharing options...
php1 Posted August 14, 2008 Author Share Posted August 14, 2008 I give the absolute path and tried .. my absolute path is /tmp/monitor/paly.wav Link to comment https://forums.phpfreaks.com/topic/119449-is-it-possible-to-make-a-link-to-the-file-stored-in-a-physical-pathnon-web-pat/#findComment-616337 Share on other sites More sharing options...
friedemann_bach Posted August 15, 2008 Share Posted August 15, 2008 Sorry, I can't help. Maybe your server does not support this for some reason I don't know. Did you think about putting the files into a protected webserver directory? Otherwise, you could also install a flash player on the webpage and play your media directly from there. Link to comment https://forums.phpfreaks.com/topic/119449-is-it-possible-to-make-a-link-to-the-file-stored-in-a-physical-pathnon-web-pat/#findComment-617329 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.