Description
int
unlink ( string filename)
Deletes filename. Similar to the Unix C
unlink() function.
Returns TRUE on success or FALSE on failure.
See also rmdir() for removing directories.
User Contributed Notes unlink |
 |
thomasj at superusers dot dk
05-Jul-2000 10:42 |
|
if you can't unlink a file it might be, that there is no write permission
for the DIRECTORY in which the file resides. Check this out.
|
|
icecube at fr dot fm
02-Jun-2001 09:31 |
|
This function should work ;)
<?php
function suppr($file)
{
$delete = @unlink($file);
if (@file_exists($file))
{
$filesys =
eregi_replace("/","\\",$file);
$delete =
@system("del $filesys");
if (@file_exists($file))
{
$delete = @chmod ($file, 0775);
$delete =
@unlink($file);
$delete = @system("del
$filesys");}}}
?>
|
|
bpotter at mamagrande dot com
30-Jun-2001 02:01 |
|
If you can't gain access to a server using unlink() try using ftp
commands:
$fp =
ftp_connect("ftp.server.com");
$login = ftp_login ($fp,
"user", "password");
ftp_delete ($fp,
$FileName);
ftp_quit($fp);
|
|
artmelkon at netscape dot net
07-Sep-2001 03:30 |
|
unlink() function dosen't work with windows98, but it dose work on
NT
with apache
server
<?php
$file="e:\\htdocs\\dev\\lnd\\test\\Copysendmail.php";
if
(file_exists($file)) {
unlink("$file");
print
"File deleted!";
} else {
print "file
exists!";
}
?>
|
|
webman at shawei dot com
10-Jan-2002 06:12 |
|
php 4.0.6 + apache + linux: we found you can use unlink function to delete
files that apache don't have write permission, even set the owner to
root.root, set mode to 0, you can still delete the file using unlink
function.
|
|
quanghoc at netzero dot net
02-Feb-2002 04:50 |
|
You can run a program to delete the program file itself. There is no
error.
thisfile.php:
<?
unlink("thisfile.php"); ?> Run thisfile.php to delete
itself. This purpose is to delete some important program file after one
time run.
|
|
mike dot scott at sk dot sympatico dot ca
14-Feb-2002 08:58 |
|
The following works great on a Win2K and IIS5 PHP platform (even the unix
path format) <? $test =
unlink("./$dir/$filename"); if ($test) { print
("Deleted file"); } ?>
|
|
rich at pulse8design dot com
26-Feb-2002 05:43 |
|
A quick note about using system() or exec() when removing files - most
decent admins will disallow the use of these functions (globally in
php.ini) for security reasons, therefore using unlink() is more portable.
|
|
venox at wastedyouth dot org
26-Apr-2002 08:35 |
|
about the ftp thing: I wouldn't recommend doing it by ftp for security
reasons. Use ftp as a last resort and make sure that the files are set to
the correct permissions. If someone gets ahold of that single source
file, they have 100% access to your site and all of it's directories.
|
|
waaagh at mageos dot com
15-Jun-2002 03:12 |
|
It worked fine with Windows XP & Easy PHP & PHP 4.02 : $link =
"./images/$cat/$pic_id$pic_extension"; if (!$a =
unlink($link)) {echo "$link non supprimé ";}
|
|
volker at duetsch dot net
18-Jul-2002 09:25 |
|
To delete all files in a specified path I use on my W2K server (apache
1.3.24 and php 4.1.1.) the following:
$path =
"c:\\htdocs\\apps\\qis\\pdf\\temp\\"; passthru ("del
$path* /q");
|
|
tomi at vacilando dot net
08-Sep-2002 01:10 |
|
If you generate and display a temporary image, you can not delete (unlink)
it immediately in the same script. Even though you generate the code to
display it, the image is really displayed only in the browser, after your
script is finished... hm, probably obvious but possibly helpful to people
like me :)
|
|
alexatkin AT maewhitman.com
10-Oct-2002 07:07 |
|
When creating a temporary image file and then sending it to the browser you
dont actually have the make a file at all,
eg:
<? header("Content-Type:
image/jpeg\n"); echo `/usr/bin/jpegtopnm
/var/www/html/clubs/photos/11.jpg | /usr/bin/pnmscale -xysize 160 120 |
/usr/bin/pnmtojpeg 2>&1`; ?>
I was quite suprised to
see that work but it could be quite useful if you have more CPU power to
spare than HD space, I know I plan to use it for a small Intranet so I
dont have to store loads of thumbnails which will rarely be used.
|
|
|
|
 |