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 6016757
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T03:01:45+00:00 2026-05-23T03:01:45+00:00

Sequel to my question here: Addslashes displays as forward slashes in php , I

  • 0

Sequel to my question here: Addslashes displays as forward slashes in php ,

I want to strip slashes from the filenames of files i have on my server. the slashes were added during file upload (magic_quotes).

Please how can i go about this? thanks

  • 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-23T03:01:46+00:00Added an answer on May 23, 2026 at 3:01 am

    Here you go:

    <?php
    $path         =  '/path/to/files/dir/';
    $file_types   =  'txt,doc,pdf';
    
    foreach (glob($path.'*.{'.$file_types.'}', GLOB_BRACE) as $filename){
        if(rename($filename , stripslashes($filename))){
            echo 'Renamed file from '.$filename.' to '.stripslashes($filename).'<br />';
        } else{
            echo 'Failed to rename file from '.$filename.' to '.stripslashes($filename).'<br />';
        }
    }
    ?>
    

    Change path to files and the comma separated list of file types.

    Update with asker’s code on the comments:

    $dir='cv'; 
    if(is_dir($dir)){ 
        if ($dh = opendir($dir)) { 
            while (false !== ($file = readdir($dh))) { 
                if ($file != "." && $file != "..") { 
                    $file2 = $dir."/".$file; $newfile=$dir."/".stripslashes(urldecode($file)); 
                    if(rename($file2, $newfile)){
                        echo "renamed from $file2 to $newfile <br>";
                    } else{
                        echo "error renaming from $file2 to $newfile <br>";
                    } 
                } 
            } 
            closedir($dh); 
        } 
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is a sequel to my (other) dumb question that I have asked today
This question is a sequel to this question (I have applied the answer, but
Note: This is a sequel to my previous question about powersets. I have got
iOS newbie question here. I have a UITabBarController as my root controller with a
Does anyone have any information on how to connect from the sequel gem to
This is the sequel to this question . I would like to combine three
when i am using sequel pro to connect to a remote database, the server
I've just installed sequel gem for Ruby. I wanted to try example from Sequel
In a sequel question to this question , my corporate environment lacks the libpython2.6.so
I am trying to understand how Sequel works. The example below inherit from Sequel::Model

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.