close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

Delete orphaned files and images

Thread began 10/27/2009 10:45 pm by troyd | Last modified 11/02/2009 9:04 pm by troyd | 7479 views | 16 replies

troyd

Wow, I did it!

Using a combination of suggestions from Jason, Brian and some from "Vacunita" in another PHP forum (would like to give credit for them but not sure if it's allowed), I now have a single page that sees all files in a directory, displays them with check boxes and deletes them if checked. No Record Set or Table required.

Basically I used DFP's delete file behavior but instead of referencing a hidden field, I referenced the checkbox value. And the check box value is assigned dynamically.

I set the form action to "" and post. Then set the trigger for the DFP behavior to "any form post".

Now I just need to figure out how to show ONLY image files. Because, as it is now, all files are showing up and can be deleted.

Here's a generic example of what I did with everyone's help. Thanks again, TroyD

php:
<?php require_once("WA_DigitalFilePro/HelperPHP.php"); ?>

<?php
$WA_DeleteFileResult1 
false;
if(
$_SERVER["REQUEST_METHOD"] == "POST"){
    
$WA_DeleteFileResult1 WA_FileAssist_DeleteFile("images/""".((isset($_POST["image"]))?$_POST["image"]:"")  ."");
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Untitled Document</title>
<style type="text/css">
<!--
img {
    width: 150px;
    }
-->
</style>
</head>
<body>
<form  action="" method="post" enctype="multipart/form-data">
  <?php
$mydir
="images/";
if (
$handle opendir($mydir)) {

    echo 
"Images:\n <table><tr><td>Delete</td><td>Filename</td></tr>";

    while (
false !== ($file readdir($handle))) {
    
    
        echo 
"<tr><td><input type='checkbox' name='image' value='$file'></td><td><img  src='$file'></td><td><img  src='images/$file' /></td><td>$file</td></tr>";
    }
echo 
"</table>";

   
closedir($handle);
}
?>
  <input name="Delete" type="submit" value="Delete" />
</form>
</body>
</html>



One thing to note for anyone still learning like me. When you go to the DFP delete behavior and click on the lightning bolt next to File name:, you won't see the check box as an option. That's because it's not recognized yet by the form since it has to be echoed I think. So I just typed in the name of the check box, in this case "image". Once it's on the server, then the check box becomes a recognized form element. (If that's not correct, please let me know).

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...