Jump to content

Is it possible to make a link to the file stored in a physical path(non-web) pat


php1

Recommended Posts

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

 

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.

 

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.

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.

 

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.

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

 

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.

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.