Jump to content

Deleting an image from a directory folder?


Solarpitch

Recommended Posts

Hey Guys,

Ok . . I finally got saving a image to a file on the server, storing the path in the table and calling the path to display the image on the web page, sorted out!

Thats all good and well . . . but how do I go about deleting the image from the folder in an application? Sure the image path from the database can be deleted easy . . but how do you get it to effect the folder on the server that holds the image?

EG: If a user click delete image . . it deletes the path in the database and the file in the directory?

Thanks in advance!
Link to comment
Share on other sites

The file you want to delete must have specific permissions on it. The web server (apache, etc) must have permission to delete that file...


try this on the file (in your linux console) before you attempt to unlink / delete it

chmod 755 {file_name}
chown www-data:www-data {file_name}

or

chmod 755 {file_name}
chown www:www {file_name}
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.