Using LC server to check for existence of mp3 on our web server?
Phil Davis
revdev at pdslabs.net
Sun Jan 22 04:16:51 EST 2017
Hi Tim,
Here is a very simplistic way of checking for a file on your server. It
assumes your mp3 files are in a 'programs' folder that resides in the
'document root' folder. This script as it is here would be in a .lc file
on your server. You pass it a filename in the url and it tells you if
the file is in the programs folder or not.
So the url would look something like this:
http://my.programserver.com/check.lc?1234.mp3
The text of the 'check.lc' file:
<?lc
set the errorMode to "inline"
put $_SERVER["QUERY_STRING"] into tFilename
put $_SERVER["DOCUMENT_ROOT"] & "/programs/" & tFilename into tPath
if there is a file tPath then
put "Found file" && q(tFilename)
else
put "Did not find file" && q(tFilename)
end if
?>
<?lc
function q pString
return quote & pString & quote
end q
?>
This is most likely not exactly what you need, but maybe it'll give you
a starting point.
Thanks -
Phil Davis
On 1/21/17 11:36 PM, Tim Selander via use-livecode wrote:
> Hi,
>
> On-rev.com hosting, using LC server to present a list of our AM/FM
> radio programs for people to listening to on-demand.
>
> Out of a month's 20 programs, 3 or 4 might not get uploaded due to
> copyright issues, etc. Also, mp3's are not on the on-rev.com server,
> but another hosting service we use as well.
>
> Filenaming is standardized, so I know the list of programs. I want to
> hit the server, if the mp3 files exists, present it as an <audio src=,
> if the mp3 file does not exists, present a "Sorry, program not
> available" message.
>
> If I wanted to check on the existence of a small text file, it would
> be fast enough for me to just get it, put it into a variable and see
> if the variable has anything in it. But mp3's are too big, so too slow.
>
> Locally, I would simply write "if there is a file 'filename'..." --
> what's the equivalent command for checking on existence of a file on a
> server?
>
> Thanks in advance.
>
> Tim Selander
> Tokyo, Japan
>
>
>
>
>
>
>
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>
--
Phil Davis
More information about the use-livecode
mailing list