View Full Version : How can I run a file from within PHP?


hvlav79
08-24-2004, 11:49 AM
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!

Pyrrhonist
08-24-2004, 11:59 AM
I haven't done much shell scripting on windows with php, but in Unix, you can often use the passthru() function to run a command. It might or might not work.