Questions tagged [unlink]

Refers to removing a file from a filesystem.

This tag is appropriate for questions about deleting a file from a filesystem whether by using a language-specific function such as Perl or PHP's unlink or by making a system call such as Unix's unlink.

Wikipedia has more information about unlink.

526 questions
6
votes
7 answers

How to avoid UNLINK security risks in PHP?

I'm using UNLINK with PHP and AJAX. I know that in this way is very dangerous, because everyone can delete any files. But I need to use AJAX because I can't reload the page when I delete the files. So how should I do to allow to delete the file only…
Adam Halasz
  • 57,421
  • 66
  • 149
  • 213
6
votes
11 answers

Cannot unlink file in Codeigniter

In my project I have a folder secure in root. The project package looks like: application secure system ........... Inside secure folder I am uploading some images on form submit using $config1['upload_path'] = './secure/'; $ext =…
Jenz
  • 8,280
  • 7
  • 44
  • 77
6
votes
2 answers

PHP Delete all files that contain a given string

I have a basic cache system setup which saves a file based on the parameters in the url so that if that page gets viewed again it accesses the static file. eg if my url is http://www.example.com/female/?id=1 I have a file located in a cache folder…
ak85
  • 4,154
  • 18
  • 68
  • 113
5
votes
2 answers

php unlink file

I've such a situation. I want to delete .wav file which is out of webroot directory , but I've defined in httpd.conf (apache) alias of this directory like "mp3" . this is working nicely, because I can download file from webroot and so on ... But I…
DaHaKa
  • 161
  • 1
  • 1
  • 6
5
votes
3 answers

PHP recursive delete function

I wrote recursive PHP function for folder deletion. I wonder, how do I modify this function to delete all files and folders in webhosting, excluding given array of files and folder names (for ex. cgi-bin, .htaccess)? BTW to use this function to…
heron
  • 3,611
  • 25
  • 80
  • 148
5
votes
2 answers

How to unlink or log out of dropbox account on iOS

I am using Dropbox in my own app. Once I login, the tableview is displayed and every time I load that view, I go straight to the table view. But, my concern is, suppose different people are using this application, they might want to login with…
Namratha
  • 16,630
  • 27
  • 90
  • 125
5
votes
3 answers

PHP:: How to delete a file from server after is read. Unlink() is executed before

I'm trying to delete a picture (.jpg) from server after the first time showed. But the file is deleted (unlink();) before showed. I've already tried with sleep() but this only delay the loading and after all the file is deleted before showed.
Daniel
  • 51
  • 1
  • 2
5
votes
2 answers

Is this the correct way of checking if a file exists?

I am trying to check if a file (image) exists so I can delete it before uploading the new one. This is what i've tried so far: foreach (glob("../imgs/" . $name . ".*") as $file) { if (file_exists($file)) { unlink($file); } } Is this…
SomeBeginner
  • 49
  • 1
  • 3
  • 17
5
votes
2 answers

Delete all files in a certain directory that their names start with a certain string in node js

I want to delete all files that there file names start with the same string in a certain directory, for example I have the following directory: public/ profile-photo-SDS@we3.png profile-photo-KLs@dh5.png profile-photo-LSd@sd0.png …
Karim
  • 198
  • 1
  • 10
5
votes
3 answers

WordPress removing original image after resize?

In wordpress media library is there any way to remove original image after a resize? It seems to keep the original and I feel this wastes a lot of space.
Jonny Jordan
  • 367
  • 1
  • 4
  • 15
5
votes
2 answers

Perl: Undo unlink with file open

unlink does not delete a file, if it is open; it just removes the name and the link to the name. Can unlink be undone? open(my $fh, ">", undef) || die; print $fh "foo"; # This does not work link($fh,"/tmp/bar") || die; Can an open file handle to an…
Ole Tange
  • 31,768
  • 5
  • 86
  • 104
5
votes
1 answer

System calls in Linux that can be used to delete files

What are the system calls that can be used to delete a file on Linux? I am not referring to just the system calls used by the libc-wrapper(which in-turn are used by command line tools). Other than unlink and unlinkat what are the system calls that…
user277465
5
votes
3 answers

how to change symlink target while preserving inode

Normally to change a symlink target one will first unlink the file and then re-creating the symlink with the new target path. However it will be assigned a new inode number. Maybe there is a private Mac api with an update_target_for_symlink()…
neoneye
  • 50,398
  • 25
  • 166
  • 151
5
votes
2 answers

unlink() not working while I try to remove an image PHP

I am trying to remove an image from a directory using the unlink() function. if (file_exists($oldPicture)) { unlink($oldPicture); echo 'Deleted old image'; } else { echo 'Image file does not exist'; } The value of $oldPicture is…
BRBT
  • 1,467
  • 8
  • 28
  • 48
5
votes
2 answers

PHP unlink OR rewrite own/current file by itself

Task: Cut or erase a file after first walk-through. i have an install file called "index.php" which creates another php file.
Email
  • 2,395
  • 3
  • 35
  • 63
1 2
3
35 36