Help make File Directory

I am new to PHP. I have only done some minor php things such as modify and rebuilding a drupal theme and such. Now, I am trying to create a File Directory. It is going to be a product directory. Where there will be links to Hi Res photo, Lo Res photo, and video, misc content for each product(for download). The clients website is set up using wordpress so I was trying to find a module that does what I want but I cant find one. Anyway, the structure is that I have Product Categories. Once you click on a product category it will take you to that product categories File Directory. So, you will see a list of the products in that category. At this stage I want the list to be populated with a thumbnail preview…with an option to enlarge into a shadowbox. I then want a txt file to be printed with Product name and skew number and then I want Check boxes for Hi Res, Lo Res, Misc. The check boxes are so people can download these files in a batch. I will have a download all Photos button and then a download selected items button. So, far I only have the basics done as you can see from my script below. All I have done so far is open up a folder to view contents. All of which link to item. But thats not enough. I have not added any style or layout to this at all yet. I just want to get the calls to funtion first. I would prefer for this to be able to pull from folders so that things can be uploaded via ftp versus each individual file. Any direction would be greatly appreciated.

[php]<?PHP

// Define the full path to your folder from root
$path = “play/”;

// Open the folder
$dir_handle = @opendir($path) or die(“Cannot open the file $path”);

// Loop through the files
while ($file = readdir($dir_handle)) {

if($file == “.” || $file == “.” || $file == “index.php” || substr($file,-3) == “txt” )

continue;

$fichierexp = $path."/".$file.".txt";
$TheLinkedFile = $path."/".$file;
if(file_exists($fichierexp)) {
@$fp = fopen($fichierexp,‘r’);
echo “<a href=”$TheLinkedFile" rel=“nofollow” target=“blank”>".fgets($fp,999)."
";
fclose($fp);
} else {
echo “<a href=”$TheLinkedFile" rel=“nofollow” target=“blank”>".substr($file,0,44)."
";
}
}
// Close
closedir($dir_handle);
?>[/php]

to create a directory you need to use the php function mkdir() like so:
[php]
mkdir(‘images/products’, 0777);
[/php]
now the 0777 does not mean that you are chmodding the directory to 0777, it just means you are allowing 0777 to be the highest it can be chmodded to, so since you are going to be uploading images to that file you will need to chmod it to 0777 so you would do it like this

[php]
mkdir(‘images/products’, 0777);
chmod(‘images/products’, 0777);
[/php]

Sponsor our Newsletter | Privacy Policy | Terms of Service