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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T05:49:11+00:00 2026-05-28T05:49:11+00:00

I am trying to unlink a file but the PHP unlink function seems to

  • 0

I am trying to unlink a file but the PHP unlink function seems to refer to the directory of the script file I am using rather then where the file is.

I am using change directory (chdir) to change the directory and yet this is seemingly having no effect:

chdir("themes");
    $file_path = getcwd()."/".$_GET["file_path"]."/";
    $deleted_file=$file_path.$data["file_name"];
    $fh = fopen($deleted_file, 'w') or die("Can't open file");
    fclose($fh);
    unlink($deleted_file);

The error I get is the following:
Warning: fopen(/home/mow/public_html/mysite/themes/_default/admin/testfile.php/): failed to open stream: No such file or directory in /home/mow/public_html/mysite/themes/_default/admin/file_manager.php on line 223

  • 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-28T05:49:11+00:00Added an answer on May 28, 2026 at 5:49 am

    It looks to me like your 'file_name' GET variable ends with a slash. Try ensuring that isn’t the case.

    NB: Make really, really, really sure that nobody you don’t completely trust will have the ability to access this script.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hey i'm trying to make my website delete a file using the unlink(); function.
I am trying to delete a file from the server using the unlink( )
I'm trying to remove a directory with PHP. I unlink/remove all files/subdirs from the
Trying to do this sort of thing... WHERE username LIKE '%$str%' ...but using bound
I'm a beginner at PHP, and I'm still trying to work out proper file
I'm trying to delete old SVN files from directory tree. shutil.rmtree and os.unlink raise
I am trying to create a file with PHP here is my code: $file_to_send
i'm trying to create a zip script based on what I've found here but
I'm trying to create function which removes all file and directories on webhosting excluding
I'm trying to delete a file with jQuery's $.ajax and php. I have the

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.