close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

Showing and then deleting files on the server

Thread began 8/17/2009 8:41 am by dave172661 | Last modified 8/17/2009 3:08 pm by dave172661 | 2648 views | 2 replies

anonymous

Dave,

There are couple of ways to do this, but I'll go through the way I have done a similar application.

The first thing to do is to get the contents of the image folder (this is assuming that all images are located in the same folder).

You can use a PHP function "scandir('imagefolderhere')" to learn about what is contained in a particular folder. You could create an array first, such as:

$mynewimagearray = scandir('imagefolder');



After doing that, you could loop through the results - but make sure you only accept results that are truly images - because remember, there will be hidden "notes" files in there, as well.

To make sure you loop through image files only, you could run something like the getimagesize command on each item in the loop. Running getimagesize is nice because it will return the boolean value of FALSE if the item is not an image and therefore cannot be read by getimagesize.

So within the loop of array items you would create an if statement. If the Boolean value is TRUE - meaning that getimagesize actually reads the image and can get values you will let it display to the browser, as such:

$checkifimage = getimagesize['$arrayitem']; 
if ($checkifimage) {
echo "<img src="yourimage">";
}



Now the code above is the most basic form... I would probably close out the PHP tags so I could just add basic HTML between and include the checkbox beside each item like this:

if ($checkifimage) } ?>

ADD WHAT EVER YOU WANT HERE... just remember that all PHP variable will have to be inside a PHP tag set

<?php } ?>



You could put your check box then right beside the image output and then wrap the entire thing inside a form. You could then make the value of the checkboxes - if checked - equal to the array item itself as that is also providing the name for the image source.

To, turn the images into thumbnails, you will need to use a script that does thumbnails on the fly. There are several out there and your image source name will change to look something like this:

<img src="resizescript.php?filename=$arrayItem&width=100&height=100">



Please note that the code above is arbitrary and just happens to be similar to code I used before where the $arrayItem is the actual image being resized by the script and the width and height attributes tell the script what dimensions to resize to.

The final step would be to get all the values checked and store them into an array - then loop through that array with the Digital File Pro delete behavior added into the loop so that it deletes each specified file.

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...