PHP SOLUTIONS: DYNAMIC WEB DESIGN MADE EASY 3. Create a form inside imagelist.php, and insert a element with just one like this: Select an image This is the only static element in the drop-down menu. 4. Amend the code in the previous step like this (new code is shown in bold): Select an image Make sure that the pathnames to the include file and the images folder are correct for your site s folder structure. If you re using PHP 4, the two lines in the PHP code block need to refer to the PHP 4 version of the function like this: include(’../includes/buildFileList4.php’); buildImageList4(’../images’); For brevity, I m not using the techniques in Chapter 4 for checking that the include file exists. 5. Save imagelist.php and load it into a browser. You should see a drop-down menu listing all the images in your images folder, as shown in Figure 7-1. When incorporated into an online form, the filename of the selected image appears in the $_POST array identified by the name attribute of the element in this case, $_POST[’pix’]. That s all there is to it! You can adapt this function to display any type of file simply by changing the filename extensions listed in the $fileTypes array (highlighted in bold on line 7 in the following listing). This listing shows the PHP 5 version; the PHP 4 version is identical except for the way it opens and inspects the directory: function buildFileList5($theFolder) { // execute code if the folder can be opened, or fail silently if ($contents = @ scandir($theFolder)) { // initialize an array for matching files $found = array(); // Create an array of file types If you are looking for affordable and reliable webhost to host and run your business application visit our ftp web hosting services. This entry was posted on Monday, January 28th, 2008 at 1:24 pm and is filed under MYSQL5. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.
This is the only static element in the drop-down menu. 4. Amend the code in the previous step like this (new code is shown in bold): Select an image Make sure that the pathnames to the include file and the images folder are correct for your site s folder structure. If you re using PHP 4, the two lines in the PHP code block need to refer to the PHP 4 version of the function like this: include(’../includes/buildFileList4.php’); buildImageList4(’../images’); For brevity, I m not using the techniques in Chapter 4 for checking that the include file exists. 5. Save imagelist.php and load it into a browser. You should see a drop-down menu listing all the images in your images folder, as shown in Figure 7-1. When incorporated into an online form, the filename of the selected image appears in the $_POST array identified by the name attribute of the element in this case, $_POST[’pix’]. That s all there is to it! You can adapt this function to display any type of file simply by changing the filename extensions listed in the $fileTypes array (highlighted in bold on line 7 in the following listing). This listing shows the PHP 5 version; the PHP 4 version is identical except for the way it opens and inspects the directory: function buildFileList5($theFolder) { // execute code if the folder can be opened, or fail silently if ($contents = @ scandir($theFolder)) { // initialize an array for matching files $found = array(); // Create an array of file types If you are looking for affordable and reliable webhost to host and run your business application visit our ftp web hosting services. This entry was posted on Monday, January 28th, 2008 at 1:24 pm and is filed under MYSQL5. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.
Make sure that the pathnames to the include file and the images folder are correct for your site s folder structure. If you re using PHP 4, the two lines in the PHP code block need to refer to the PHP 4 version of the function like this: include(’../includes/buildFileList4.php’); buildImageList4(’../images’); For brevity, I m not using the techniques in Chapter 4 for checking that the include file exists. 5. Save imagelist.php and load it into a browser. You should see a drop-down menu listing all the images in your images folder, as shown in Figure 7-1. When incorporated into an online form, the filename of the selected image appears in the $_POST array identified by the name attribute of the element in this case, $_POST[’pix’]. That s all there is to it! You can adapt this function to display any type of file simply by changing the filename extensions listed in the $fileTypes array (highlighted in bold on line 7 in the following listing). This listing shows the PHP 5 version; the PHP 4 version is identical except for the way it opens and inspects the directory: function buildFileList5($theFolder) { // execute code if the folder can be opened, or fail silently if ($contents = @ scandir($theFolder)) { // initialize an array for matching files $found = array(); // Create an array of file types If you are looking for affordable and reliable webhost to host and run your business application visit our ftp web hosting services.
This entry was posted on Monday, January 28th, 2008 at 1:24 pm and is filed under MYSQL5. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.
Name (required)
Mail (will not be published) (required)
Website