Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6806743
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T19:44:53+00:00 2026-05-26T19:44:53+00:00

Possible Duplicate: How do I recursively delete a directory and its entire contents (files+sub

  • 0

Possible Duplicate:
How do I recursively delete a directory and its entire contents (files+sub dirs) in PHP?
PHP: delete directory with files in it?

I am working with an site where I have to store four images of different formats by creating a directory in an specified folder. I have created the directory and inserted the images into it. Now my problem is I am unable to delete the directory with all the images.

Suppose I have,

$path = "offer_pic/";

$directory = $r2['shop_name'];

$realpath=$path.$directory.'/';

How do I delete all of the images inside $realpath, as well as the directory itself ($directory)?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T19:44:53+00:00Added an answer on May 26, 2026 at 7:44 pm

    This will do it, just be careful you don’t delete the whole server:

    $dir='your/directory';
    exec('rm -rf '.escapeshellarg($dir));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: How do I recursively delete a directory and its entire contents (files+sub
Possible Duplicate: How to recursively list all the files in a directory in C#?
Possible Duplicate: How to recursively list all the files in a directory in C#?
Possible Duplicate: How do you get a directory listing in C? Listing directory contents
Possible Duplicate: How do I get a directory size (files in the directory) in
Possible Duplicate: How do I sort a multidimensional array in php I have multidimensional
Possible Duplicate: Using Emacs to recursively find and replace in text files not already
Possible Duplicate: Recursively create directory What's the java-esque way to create a director(ies), and
Possible Duplicate: How do I make a request using HTTP basic authentication with PHP
Possible Duplicate: How can I understand nested ?: operators in PHP? Why does this:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.