close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Delete Folder

Thread began 2/14/2023 6:59 am by BillHobbs | Last modified 2/15/2023 10:02 am by Ray Borduin | 210 views | 8 replies |

BillHobbs

Delete Folder

I created a client page that allows my clients to create a project, the page allows them to create a project, give details and then creates a folder that they can upload files in to.

My issue is once I've viewed and downloaded the files I want to clear the files and the created folder off the server. I can delete the files without any trouble. I just don't see a way to delete the newly created folder after the files have been deleted. Can digital file pro do this, or is there some other way this is handled?

Sign in to reply to this post

Ray BorduinWebAssist

You would have to do it manually. It should be easy enough to do... if you use the function:

rmdir("foldername");

That will remove a directory as long as it is empty.

Sign in to reply to this post
Did this help? Tips are appreciated...

BillHobbs

Thank you that seemed to work.

<?php $folder = 2; ?>
<?php
rmdir($folder);
?>

How would I change the path to the folder? From my admin folder the path would be
../clientuploads/thefoldername

Thanks, hope you are mending.

Sign in to reply to this post

Ray BorduinWebAssist

I'm not sure I understand the question. There is no trick to it, you can put in the full path and use ../ to navigate to sub directories.

Sign in to reply to this post
Did this help? Tips are appreciated...

BillHobbs

<?php
rmdir($folder);
?>
$folder is the dynamic name of the folder, but it is inside the same directory as the admin page that I'm deleting from. So my question is how do I apply the path to the folder?

Maybe this?

<?php
rmdir(../clientuploads/$folder);
?>

Sign in to reply to this post

Ray BorduinWebAssist

I see... yes something like that:


<?php
rmdir("../clientuploads/" . $folder);
?>

Sign in to reply to this post
Did this help? Tips are appreciated...

BillHobbs

Here is what I came up with.

<form method="post">
<input name="delete" type="submit" class="Button" value="Delete Folder">
</form>
<?php
if(isset($_POST['delete']))
{
rmdir("../clientuploads/" . $folder);
}
?>

This seems to work. I'm using Digital File Pro to delete the files before I delete the folder. Is it possible to add this to the Digital File Pro code to delete the folder once the files are deleted. Or can I only create another button to delete the folder separately?

Here is the Digital File Pro code.

<?php
if (isset($_POST["DeleteButton"]) || isset($_POST["DeleteButton_x"])) {
$UpdateQuery = new WA_MySQLi_Query($connSiteDB);
$UpdateQuery->Action = "update";
$UpdateQuery->Table = "clientuploads";
$UpdateQuery->bindColumn("clientuploadComplete", "s", "".((isset($_POST["Complete"]))?$_POST["Complete"]:"") ."", "WA_BLANK");
$UpdateQuery->addFilter("clientuploadID", "=", "i", "".((isset($_POST["projectID"]))?$_POST["projectID"]:"") ."");
$UpdateQuery->execute();
$UpdateGoTo = "manage_client_projects.php?clientID=".($rsProject->getColumnVal("clientuploadClientID")) ."";
if (function_exists("rel2abs")) $UpdateGoTo = $UpdateGoTo?rel2abs($UpdateGoTo,dirname(__FILE__)):"";
$UpdateQuery->redirect($UpdateGoTo);
}
?>
<?php
$WA_DeleteFileResult1 = false;
if(isset($_POST["DeleteButton"]) || isset($_POST["DeleteButton_x"])){
$WA_DeleteFileResult1 = WA_FileAssist_DeleteFile("../clientuploads/".($rsProject->getColumnVal("clientuploadID")) ."", "".($rsUploadedFiles->getColumnVal("clientfiles1")) ."");
}
?>
<?php
$WA_DeleteFileResult1 = false;
if(isset($_POST["DeleteButton"]) || isset($_POST["DeleteButton_x"])){
$WA_DeleteFileResult1 = WA_FileAssist_DeleteFile("../clientuploads/".($rsProject->getColumnVal("clientuploadID")) ."", "".($rsUploadedFiles->getColumnVal("clientfiles2")) ."");
}
?>
<?php
$WA_DeleteFileResult1 = false;
if(isset($_POST["DeleteButton"]) || isset($_POST["DeleteButton_x"])){
$WA_DeleteFileResult1 = WA_FileAssist_DeleteFile("../clientuploads/".($rsProject->getColumnVal("clientuploadID")) ."", "".($rsUploadedFiles->getColumnVal("clientfiles3")) ."");
}
?>
<?php
$WA_DeleteFileResult1 = false;
if(isset($_POST["DeleteButton"]) || isset($_POST["DeleteButton_x"])){
$WA_DeleteFileResult1 = WA_FileAssist_DeleteFile("../clientuploads/".($rsProject->getColumnVal("clientuploadID")) ."", "".($rsUploadedFiles->getColumnVal("clientfiles4")) ."");
}
?>
<?php
$WA_DeleteFileResult1 = false;
if(isset($_POST["DeleteButton"]) || isset($_POST["DeleteButton_x"])){
$WA_DeleteFileResult1 = WA_FileAssist_DeleteFile("../clientuploads/".($rsProject->getColumnVal("clientuploadID")) ."", "".($rsUploadedFiles->getColumnVal("clientfiles5")) ."");
}
?>

Sign in to reply to this post

Ray BorduinWebAssist

You could probably just add it manually after the delete file like:

php:
<?php

$WA_DeleteFileResult1 
false;
if(isset(
$_POST["DeleteButton"]) || isset($_POST["DeleteButton_x"])){
$WA_DeleteFileResult1 WA_FileAssist_DeleteFile("../clientuploads/".($rsProject->getColumnVal("clientuploadID")) ."""".($rsUploadedFiles->getColumnVal("clientfiles1")) ."");
@
rmdir("../clientuploads/" $rsProject->getColumnVal("clientuploadID"));
}
?>



That would remove the folder if it was empty after deleting the file and do nothing if there were still files in that folder.

Sign in to reply to this post
Did this help? Tips are appreciated...

BillHobbs

Thanks, this worked perfectly.

Sign in to reply to this post

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