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
825
votes
39 answers

Unlink of file Failed. Should I try again?

Something wrong is going on with one of the files in my local git repository. When I'm trying to change the branch it says: Unlink of file 'templates/media/container.html' failed. Should I try again? (y/n) What could that mean?
Pol
  • 24,517
  • 28
  • 74
  • 95
224
votes
10 answers

PHP - Move a file into a different folder on the server

I need to allow users on my website to delete their images off the server after they have uploaded them if they no longer want them. I was previously using the unlink function in PHP but have since been told that this can be quite risky and a…
odd_duck
  • 3,941
  • 7
  • 43
  • 85
45
votes
9 answers

PHP unlink() handling the exception

Well, I have been wondering if I can handle the unlink() function properly. I dont want the unlink() function to throw some nasty error if it is unable to unlink the file (may be due to the File not found). I tried something like try { …
prakashchhetri
  • 1,806
  • 4
  • 36
  • 61
41
votes
5 answers

Relinking an anonymous (unlinked but open) file

In Unix, it's possible to create a handle to an anonymous file by, e.g., creating and opening it with creat() and then removing the directory link with unlink() - leaving you with a file with an inode and storage but no possible way to re-open it. …
ijw
  • 4,376
  • 3
  • 25
  • 29
34
votes
9 answers

PHP: Unlink All Files Within A Directory, and then Deleting That Directory

Is there any way I can use RegExp or Wildcard searches to quickly delete all files within a folder, and then remove that folder in PHP, WITHOUT using the "exec" command? My server does not give me authorization to use that command. A simple loop of…
rolling_codes
  • 15,174
  • 22
  • 76
  • 112
33
votes
6 answers

permission denied - php unlink

I have two files: b.php and test.txt and the error is: Warning: unlink(test.txt) [function.unlink]: Permission denied why? b.php and test.txt is 777 and the same group/login if I set 777 on the parent…
eugui
  • 461
  • 1
  • 5
  • 13
31
votes
2 answers

Delete files which has the same prefix

$prefix = 'something_prefix'; unlink($prefix.'.*'); the code above is not working, but I see some code like this below works just fine unlink('*.jpg'); why? I am wonder is this going to work? unlink('*.*'); how to delete the files which they…
castiel
  • 2,675
  • 5
  • 29
  • 38
21
votes
8 answers

Guaranteed file deletion upon program termination (C/C++)

Win32's CreateFile has FILE_FLAG_DELETE_ON_CLOSE, but I'm on Linux. I want to open a temporary file which will always be deleted upon program termination. I could understand that in the case of a program crash it may not be practical to guarantee…
John Zwinck
  • 239,568
  • 38
  • 324
  • 436
18
votes
7 answers

What is the difference between delete() and unlink() in PHP

When I started searching for "How to delete a file in PHP" The solution I got almost everywhere is "unlink()" But in w3schools I met with another function named delete(). Here is that link delete() function w3schools And I started surfing about…
Rakesh
  • 400
  • 2
  • 5
  • 19
16
votes
2 answers

Deleting file in Node.js

I am using node in a Windows environment. When I use fs.unlinkSync(fileName), it seems to work. After the unlinkSync statement is executed, if I do a fs.existsSync(filename) it returns false indicating the file does not exists, but when I go to the…
user1961100
  • 399
  • 3
  • 6
  • 15
15
votes
9 answers

Deleting a File using php/codeigniter

I would like to delete a file that is found in my localhost. localhost/project/folder/file_to_delete I'm using codeigniter for this. I would like to use the unlink() function in php but I really can't understand how to use it.
Jetoox
  • 1,387
  • 6
  • 17
  • 36
14
votes
5 answers

php - unlink throws error: Resource temporarily unavailable

Here is the piece of code: public function uploadPhoto(){ $filename = '../storage/temp/image.jpg'; file_put_contents($filename,file_get_contents('http://example.com/image.jpg')); $photoService->uploadPhoto($filename); echo("If file…
Abhishek Reddy
  • 342
  • 1
  • 2
  • 12
14
votes
2 answers

(node.js module) sharp image processor keeps source file open, unable to unlink original after resize

I'm using sharp to resize an uploaded image in a Node.js / Express application written in Typescript. After successful resizing, I'd like to delete the original file. For png and gif input images, the operation terminates successfully, I have the…
András Szepesházi
  • 6,483
  • 5
  • 45
  • 59
13
votes
2 answers

Change read/write permissions on a file descriptor

I'm working on a linux C project and I'm having trouble working with file descriptors. I have an orphan file descriptor (the file was open()'d then unlink()'d but the fd is still good) that has write-only permission. The original backing file had…
Andrew Klofas
  • 610
  • 1
  • 7
  • 19
13
votes
5 answers

How to use Unlink() function

I'm trying to use PHP unlink() function to delete away the specific document in the folder. That particular folder has already been assigned to full rights to the IIS user. Code: $Path = './doc/stuffs/sample.docx'; if (unlink($Path)) { echo…
JLearner
  • 1,271
  • 9
  • 27
  • 40
1
2 3
35 36