Welcome Guest, Not a member yet? Register   Sign In
How to delete the file
#1

Hello. Please forgive me for so newbie question, however I have already read documentation several times, but I didn't find an answer.
I have to delete file which is placed on $file = base_url()."uploads/images/".$filename
Please give me some examples how to do it?
Reply
#2

File deletion is not part of a framework but a native php function. You are looking for the function unlink() (http://php.net/manual/en/function.unlink.php)

A small note, you cant delete a file based on the URL, the example you provide refers to a url (http://somedomain.com/uploads/images/somefile.jpg), you need to provide the (filebased) path to the file, for example:

PHP Code:
unlink(APPPATH '/uploads/images/somefile.jpg'); 
Reply
#3

(This post was last modified: 01-22-2016, 08:14 AM by meow.)

(11-24-2015, 03:20 AM)Diederik Wrote: File deletion is not part of a framework but a native php function. You are looking for the function unlink() (http://php.net/manual/en/function.unlink.php)

A small note, you cant delete a file based on the URL, the example you provide refers to a url (http://somedomain.com/uploads/images/somefile.jpg), you need to provide the (filebased) path to the file, for example:

PHP Code:
unlink(APPPATH '/uploads/images/somefile.jpg'); 

Thanks! Here are some more paths listed under CONSTANTS:
http://www.codeigniter.com/user_guide/ge...ht=apppath
Reply




Theme © iAndrew 2016 - Forum software by © MyBB