Domanda

I have LAMP server and a recordings server with small audio files. I would like to be able to access the audio files and embed them on a web page on the LAMP server. I do not want to create a share on the recordings server cause there are to many servers I need to do this to. I was thinking of the ssh2_sftp command in php but once I get the file via ssh2-sftp how can I embed that in the page? Also the audio files are available via HTTP but prefer not to do it that way the recordings server can be accessed via the local network.

UPDATE 7/15/2013

Ok I have figured out how to get access to the file on the local recordings server. But now I am having trouble embedding this the audio file in the page so the user can listen to it.

<?php
$connection = ssh2_connect('IP', 22);
ssh2_auth_password($connection, 'USERNAME', 'PASSWORD');

$sftp = ssh2_sftp($connection);

$stream = fopen("ssh2.sftp://$sftp/$path/$filename", 'r');
?>
È stato utile?

Soluzione

Your idea of using ssh2_sftp would work (or any type of copy command, for that matter - even just scp), to copy the files from the remote recordings server to the lamp server. Just copy the files to a web-accessible directory on the LAMP server, then your web pages can link to these files via their respective URL's. The whole thing (including the copy) can be done on the fly in PHP.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top