Apache, PHP on external HD?
I've been working with someone who tried to write me up some php code to make it work, however, he said I need to have apache and php installed. I've enabled web sharing, but that still didn't allow the code he provided to work.
Do I need to somehow install apache and php on that hard drive directly or is there something else I need to do?
Also, if anyone has any comments or suggestions for a solution to my main objective, please opine. I'm very open to suggestions. Please remember, coding/scripting languages are gibberish to me, but I am very good at following directions. Here also are two different version of php that my friend provided to accomplish this project. Feel free to inspect it and comment.
<?php
$current_dir = "$DOCUMENT_ROOT"."dirname/"; //Put in second part, the directory - without a leading slash but with a trailing slash!
$dir = opendir($current_dir); // Open the sucker
echo ("<p><h1>List of available files:</h1></p><hr><br />");
while ($file = readdir($dir)) // while loop
{
$parts = explode(".", $file); // pull apart the name and dissect by period
if (is_array($parts) && count($parts) > 1) { // does the dissected array have more than one part
$extension = end($parts); // set to we can see last file extension
if ($extension == "ext" OR $extension == "EXT") // is extension ext or EXT ?
echo "<a href=\"$file\" target=\"_blank\"> $file </a><br />"; // If so, echo it out else do nothing cos it's not what we want
}
}
echo "<hr><br />";
closedir($dir); // Close the directory after we are done
?>
This can be used to list certain file extensions. If you want it to list all files, use this code:
<?php
$current_dir = "$DOCUMENT_ROOT"."dirname/"; //Put in second part, the directory - without a leading slash but with a trailing slash!
$dir = opendir($current_dir); // Open the sucker
echo ("<p><h1>List of available files:</h1></p><hr><br />");
while ($file = readdir($dir)) // while loop
{
echo "<a href=\"$file\" target=\"_blank\"> $file </a><br />"; // creates link to file
}
echo "<hr><br />";
closedir($dir); // Close the directory after we are done
?>
Remember to change "dirname/" to the directory you want to list. If you want to place the php file in the directory you want listed, eliminate "dirname/" and leave it "/"
iMac 2.4GHz Aluminum, Mac OS X (10.4.11)
