1

Trying to delete files from server but receive this error:

unlink(): cURL does not allow unlinking in...

Here is my code:

foreach($fDel as $del=>$delval){
$paths = array("art/images/", "art/smallthumbs/", "art/thumbs/");
$imgid = $delval['img_id'];

$fileNm = $delval['img_fname'];
foreach($paths as $x=>$path) { 
$file = URL . $path . $fileNm.".jpg";
unlink($file);  
}

}

1 Answers1

0

unlink PHP function delete files by full root server path, so you must:

if ( file_exists(__DIR__ .'/'. $path . $fileNm .".jpg") ) {
    unlink(__DIR__ .'/'. $path . $fileNm .".jpg");
} else {
    die('File not exists!');
}

where art/images dir must placed in __DIR__.

Victor Bocharsky
  • 11,930
  • 13
  • 58
  • 91