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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T16:42:55+00:00 2026-05-24T16:42:55+00:00

I am having trouble with unlink in php… The files in the directory are

  • 0

I am having trouble with unlink in php… The files in the directory are uploaded with php form.

ls -l of /files/uploads/

total 6976
-rw-r--r--  1 alex  admin   689030 15 Aug 11:40 01805_goneclubbing_1680x1050.jpg
-rwxrwxrwx  1 alex  admin   174932 15 Aug 11:52 4vvF60D.tmp.jpg
-rw-r--r--  1 alex  admin  2699554 15 Aug 12:16 example.JPG

php script (cakePHP framework):

$file_path = '/files/uploads/';
    $file_name = $file['Upload']['path'];

    $classroom_id = $file['Upload']['classroom_id'];

        if (unlink($file_path . $file_name)) {

            if ($this->Upload->delete($id)) {
                $this->setFlash('File deleted');
                $this->redirect(array('controller' => 'classrooms', 'action' => 'view', $classroom_id));
            }

        }

php error:

Warning (2): unlink(/files/uploads/example.JPG) [function.unlink]: No such file or directory [APP/controllers/uploads_controller.php, line 55]

I searched on stackoverflow, tried giving 777 permissions and still not working. I can access the image through the browser at that path.

Thanks for the help!

  • 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-24T16:42:56+00:00Added an answer on May 24, 2026 at 4:42 pm

    On any UNIX system, / is your system root. So when you try to access /files, you try to access a folder files located at your system root. I think you want to access /path_to_www/files, so either use a variable which stores your base path or use a relative path.

    On the other hand, when you try to access /files from your web browser, it reaches the / of your web directory (or an alias path). So it is totally normal that you can access your image from your browser but not from php.

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

Sidebar

Related Questions

Having trouble getting JQuery to access the parent form field 'inputStart's value when a
Having trouble getting my POST arrays to show all checkbox values from my form.
I'm having trouble deleting images from a mysql database using php. The addition of
Having trouble getting my form to UPDATE records in my database even after searching
Having trouble linking the Stomp.framework into an iPhone SDK application. http://code.google.com/p/stompframework/ I follow the
Having trouble with proper regex for RewriteCond RewriteCond %{REQUEST_URI} !^/foo/ Works as expected, that
Having trouble with the following segment of code. I'm getting a parameter count mismatch.
Having Trouble with Entity Framework. I have been populating EntityReferences with an EntityKey inorder
Having trouble finding an explanation in the docs, would someone be kind enough to
Having trouble with recursive methods in c#. When compiled it should just display 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.