Menu
  • HOME
  • TAGS

php function to check when an uploaded image has been in the directory for longer than a day

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...

Receiving unlink() error after it has been successful

php,runtime-error,unlink

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...

Why does Python's tempfile method unlink() require a filename?

python,temporary-files,unlink

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...

Delete image row and delete image from directory

php,mysql,unlink

This should work $deletepics = DB::getInstance()->delete('gallery', array('id', '=', $id)); unlink('../../images/gallery/'.$pic); ...

PHP unlink() issues

php,permissions,mkdir,unlink

unlink — Deletes a file and rmdir() - Removes directory You have a directory. You need to use rmdir, not unlink....

PHP Code works well in XAMPP but results an error at my webhost [duplicate]

php,simplexml,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....

unlink not working with space in foldername path

php,spaces,unlink

$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); ...

Finding empty folders recursively and delete them recursively

php,recursion,unlink,is-empty

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...

PHP unlink fails to unlink zip-file - still returns true

php,xampp,unlink

The embarrassing reason why it "didn't work" just was based on the fact that i was looking at the wrong directory.

How to remove image from web root when data edit and update by cakephp

php,cakephp,unlink

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.....'; } ...

Delete a file from the server using unlink

php,chmod,unlink

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...

PHP - unlink not properly working

php,cookies,unlink

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...

C - Unlink/Remove produces error for filenames with spaces

c,file-io,unlink

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...

Delete files based on backlist word

shell,delete,unlink,blacklist

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 ...

unlink PHP works when file is in root, not if file is in folder

php,unlink

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....