3

codeigniter folder structure

application
system
user_guide
uploads

Code:

unlink('http://sale.coupsoft.com/uploads/'.$checkbox[$i]['Image']);

I want to remove file from uploads folder but I am an unable to delete file by using HTTP.How can I remove file? my coding is correct but I am using HTTP so this displaying error. I am weak in English. so please apologize me if I made any Grammatical or spelling mistakes.

Punit Gajjar
  • 4,937
  • 7
  • 35
  • 70
Shah Rushabh
  • 147
  • 4
  • 16

4 Answers4

4

you can not use image full path please add image full path /var/www/html/projectfolder/uploads/filename. See Below Codeigniter Example:

<?php 
  $url = FCPATH . 'uploads/filename';
 if (unlink($url)) {
  echo "File Successfully deleted."; 
 } 
?>
pawan sen
  • 716
  • 5
  • 14
1

Unlink does not work like that, its works on relative path, try it like this :

unlink('./uploads/'.$checkbox[$i]['Image']);
Waleed Ahmed Haris
  • 1,229
  • 11
  • 17
1

Unlink does not working like this . You should pass relative path of your file rather than absolute path. Also For any file three step neccessary as:

file_exists
realpath
is_writable

After this unlink for delete file

unlink('./uploads/'.$checkbox[$i]['Image']);
Kumar Rakesh
  • 2,718
  • 2
  • 18
  • 39
1

You can try this, it's working for mine:

$url = FCPATH.'uploads/'.$checkbox[$i]['Image'];
if (unlink($url)) {
  echo "Deleted!"; 
} 
illeas
  • 300
  • 3
  • 18