Page 1 of 1

How can I run a file from within PHP?

Posted: Tue Aug 24, 2004 6:55 pm
by hvlav79
Hi guys, I need your help!
I have written a piece of code that creates a file titled "playlist.m3u". I want to further develop the code so that the file "playlist.m3u" will be automatically played as soon as it is created through winamp. I have tried to use the exec() and system() functions but I couldn't get it to work. Are there any other commands I should know of? This is the code I have written:

<?php
if(isset($_POST['action']) AND $_POST['action']=1){
$filename = "c:/Temp/playlist.m3u";
$m3u=fopen($filename, "w") or die("cannot open $filename");
$selected=$_POST['selected'];
foreach($selected as $file){
fwrite($m3u,$file."\r\n");
}
fclose($m3u);
echo exec($filename);
}
?>

Is there someone who can help me?
Thanks in advance!

Posted: Tue Aug 24, 2004 7:00 pm
by feyd
php/apache is probably running under the SYSTEM user, which doesn't have access (directly) to Winamp. If you set the service to have interactive access to the desktop, or switch the user it runs under to one that has access rights to the drives, I believe it'll work.. although it's been a while since I've screwed around with that stuff. :)