/ Published in: PHP

Checks for image files in directory and creates a XML file of the contents
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
<?php // Initialize the xmlOutput variable $xmlBody = '<?xml version="1.0" encoding="ISO-8859-1"?>'; $dir = "images/gallery1/"; // Specify Directory where images are $xmlBody .= "<XML>"; // Start XMLBody output // open specified directory using opendir() the function // Create incremental counter variable if needed $i = 0; // if file is not a folder and if file name contains the string .jpg $i++; // increment $i by one each pass in the loop $xmlBody .= ' <Picture> <picNum>' . $i . '</picNum> <picURL>' . $dir . '' . $file . '</picURL> </Picture>'; } // close the if statement } // End while loop $xmlBody .= "</XML>"; echo $xmlBody; // output the gallery data as XML file for flash
Comments
