php,file-upload,controller,cron,unlink
Looks like you have inconsistent directory names. Try this: public function delete_gallery_images() { $dirName = '../public/images/gallery_images/files/'; $dir = opendir($dirName); if ($dir) { // Read directory contents while (false !== ($file = readdir($dir))) { if($file != "." && $file != "..") { // Check the create time of each file (older...
Possible causes to the error: There are more than 1 record in the tempFiles table with the same fileName, so the first attempt removes it and the second causes the error. The file didn't exists on the folder when you ran the script (as @AxelAmthor said on comment) To solve...
What you have discovered is an accident of implementation. There is no documented NamedTemporaryFile.unlink method, but as you've seen one does seem to exist. Specifically it is the same as os.unlink, and you should never call it yourself, because it is an undocumented (mis)feature. If you want to see the...
This should work $deletepics = DB::getInstance()->delete('gallery', array('id', '=', $id)); unlink('../../images/gallery/'.$pic); ...
unlink — Deletes a file and rmdir() - Removes directory You have a directory. You need to use rmdir, not unlink....
Function array dereferencing was first added in PHP 5.4. It's likely that your host is running 5.3. In short this means that unlink( $xml->xpath('/data//count['.$_POST["remove"].']/fulldir')[0][0] ); must be written as this: $path = $xml->xpath('/data//count['.$_POST["remove"].']/fulldir'); unlink( $path[0][0] ); So essentially, save your method result to a variable before using indexes....
$filepath = str_replace(" ", "\ ", $filepath); The problem here is that you are escaping the space character in PHP, not actually inserting a backslash. In order to actually mean a backslash, you have to escape a backslash, like so: $filepath = str_replace(" ", "\\ ", $filepath); ...
Simply iterate over your array using foreach. foreach ($filesArray as $file) { Then for each file, check if it is a folder using is_dir like this if (is_dir ($file)) { If it is a folder/directory, read the directory, for instanse using scandir. $directoryContent = scandir($file); If the result of scandir...
The embarrassing reason why it "didn't work" just was based on the fact that i was looking at the wrong directory.
Here your data can not find existing data. use this code $data1 = $this->News->findById($newsid); $this->request->data = $data1; $directory = WWW_ROOT . 'media'; if(unlink($directory.DIRECTORY_SEPARATOR.$data1['News']['image_url'])) { echo 'image deleted.....'; } ...
If I have read your question correctly, the following should work: <?php $FileName = "uploaded_file" if (unlink($FileName)) { echo ("$FileName has been deleted successfully. "); } else { echo ("The uploaded file has NOT been deleted."); } ?> If it does not. You will have to change the ownership of...
There are any number of reasons your code may be failing on one file but not the others. It doesn't appear to be a logic error, but the first thing I would do is try to rewrite this as a loop rather than using array_map(). Then I would check for...
Thank you very much for all your input, after reviewing your comments and making a few experiments myself, I figured out that remove/unlink was not working because the filename was only temporarily saved at variable cell (it was there long enough for it to be printed correctly to console, hence...
I am assuming the blacklist words are written in a file named blacklist.txt: #!/bin/bash while read line; do list=/files/*$line* for file in ${list[@]} do [[ -f $file ]] && rm $file done done < blacklist.txt ...
What about: $root = realpath($_SERVER['DOCUMENT_ROOT']); $myfile = '$root/images/theone.png'; unlink($myfile); Although to my knowledge, your attempted method should work, unless either I'm missing something, or you haven't included some code here that might be interfering with the unlink....