unlink problem

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
hame22
Forum Contributor
Posts: 214
Joined: Wed May 11, 2005 5:50 am

unlink problem

Post by hame22 »

Hi all having a small problem with an unlink command

this is my code

Code: Select all

$location = "http://directory/filename.php";

if (unlink($location))
{
 print 'file deleted';
}
when i attempt to delete the file I recieve the following error:

"unlink(http://directory/filename.php) no such file or directory"

any ideas on what could be the problem?

thnks';
}

when i attempt to delete the file I recieve the following error:

"unlink(http://directory/filename.php) no such file or directory"

any ideas on what could be the problem?

thnks

Code: Select all

$location = "http://directory/filename.php";

if (unlink($location))
{
 print 'file deleted';
}
when i attempt to delete the file I recieve the following error:

"unlink(http://directory/filename.php) no such file or directory"

any ideas on what could be the problem?

thnksame.php";

if (unlink($location))
{
print 'file deleted';
}

when i attempt to delemy code

Code: Select all

$location = "http://directory/filename.php";

if (unlink($location))
{
 print 'file deleted';
}
when i attempt to delete the file I recieve the following error:

"unlink(http://directory/filename.php) no such file or directory"

any ideas on what could be the problem?

thnksall problem with an unlink command

this is my code

Code: Select all

$location = "http://directory/filename.php";

if (unlink($location))
{
 print 'file deleted';
}
when i attempt to delete the file I recieve the following error:

"unlink(http://directory/filename.php) no such file or directory"

any ideas on what could be the problem?

thnksde

Code: Select all

$location = "http://directory/filename.php";

if (unlink($location))
{
 print 'file deleted';
}
when i attempt to delete link command

this is my code

Code: Select all

$location = "http://directory/filename.php";

if (unlink($location))
{
 print 'file deleted';
}
when i attempt to delete the file I recieve the following error:

"unlink(http://directory/filename.php) no such file or directory"

any ideas on what could be the problem?

thnksall problem with an unlink command

this is my code

Code: Select all

$location = "http://directory/filename.php";

if (unlink($location))
{
 print 'file deleted';
}
when i attempt to delete the file I recieve the following error:

"unlink(http://directory/filename.php) no such file or directory"

any ideas on what could be the problem?lete the file I recieve the following error:

"unlink(http://directory/filename.php) no such file or directory"

any ideas on what could be the problem?

thnksk command

this is my code

Code: Select all

$location = "http://directory/filename.php";

if (unlink($location))
{
 print 'file deleted';
}
when i attempt to delete the file I recieve the following error:

"unlink(http://directory/filename.php) no such file or directory"

any ideas on what could be the problem?

thnks
$location = "http://directory/filename.php";

if (unlink($location))
{
print 'file deleted';
}

when i attempt to delete the file I recieve the following error:

"unlink(http://directory/filename.php) no such file or directory"

any ideas on what could be the problem?

thnks
Syranide
Forum Contributor
Posts: 281
Joined: Fri May 20, 2005 3:16 pm
Location: Sweden

Post by Syranide »

you cannot unlink webpages, that would make it possible for you to unlike the entire windows site (would probably make someone happy).

Unlink can delete local files, that is on the same server, or on a network drive used by the local server.
hame22
Forum Contributor
Posts: 214
Joined: Wed May 11, 2005 5:50 am

Post by hame22 »

sorry my mistake, i am not trying to unlink a .php page should have said pdf which is held within my webserver, does this make any difference?
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

Moved to PHP code. And Please use

Code: Select all

tags if you're going to post PHP code. code.post PHP code. And Please use

Code: Select all

tags if you're going to post PHP code.PHP code.tags if you're going to post PHP code. And Please use

Code: Select all

tags if you're going to post PHP code.
hame22
Forum Contributor
Posts: 214
Joined: Wed May 11, 2005 5:50 am

Post by hame22 »

er? so any ideas why the pdf file is not removed from the webserver when i use the unlink command with the files address on the server?
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

Web pages, files over HTTP, anything over HTTP... you can't do it.
HTTP is pretty much read-only.

You can delete from your own file system, a remote filesystem via SSH/FTP but not via HTTP like this.

EDIT | If this file is on your own web server, i.e. the one your script is running on then drop the http://domain portion. If PHP has write access to the file then it will work ;)
Last edited by Chris Corbyn on Mon Jul 04, 2005 8:16 am, edited 1 time in total.
hame22
Forum Contributor
Posts: 214
Joined: Wed May 11, 2005 5:50 am

Post by hame22 »

ok thanks, so i guess i'll have to go back to using addresses such as ../../files/file.pdf , i'm i right in thinking this?
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

hame22 wrote:ok thanks, so i guess i'll have to go back to using addresses such as ../../files/file.pdf , i'm i right in thinking this?
Yes, see my EDIT above ;)
Post Reply