Skip to main content
Inspiring
September 5, 2006
Question

OT: PHP unlink()

  • September 5, 2006
  • 26 replies
  • 1411 views
As discussed on the PHP.Net site, I am throwing a permission denied error -

Warning: unlink(../images/users/Murray/Creek.jpg) [function.unlink]:
Permission denied in
W:\Webspace\resadmin\madison\madisonconcrete.com\www\manage\m_users_update.php
on line 82


when I try to delete an image file from a folder with this markup -

unlink('../images/users/'.$userName."/".$_POST['images']);

There are several vague workarounds there that I'm not sure I fully
followed. One of them says to make an ftp connection and then use ftp
delete to wipe the file. Is this the best way?

--
Murray --- ICQ 71997575
Adobe Community Expert
(If you *MUST* email me, don't LAUGH when you do so!)
==================
http://www.dreamweavermx-templates.com - Template Triage!
http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
http://www.dwfaq.com - DW FAQs, Tutorials & Resources
http://www.macromedia.com/support/search/ - Macromedia (MM) Technotes
==================



This topic has been closed for replies.

26 replies

Inspiring
September 5, 2006
It appears that permissions are being set at 666 when I upload the file.
This is devil spawn for sure....

--
Murray --- ICQ 71997575
Adobe Community Expert
(If you *MUST* email me, don't LAUGH when you do so!)
==================
http://www.dreamweavermx-templates.com - Template Triage!
http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
http://www.dwfaq.com - DW FAQs, Tutorials & Resources
http://www.macromedia.com/support/search/ - Macromedia (MM) Technotes
==================


"David Powers" <david@example.com> wrote in message
news:edk19s$sn9$1@forums.macromedia.com...
> Murray *ACE* wrote:
>> unlink("..\\images\\users\\".$userName."\\".$_POST['images']);
>>
>> That line (line 82) gives me this error -
>>
>> Parse error: parse error, unexpected T_STRING
>
> It may not solve your problem, but you don't need to use the concatenation
> operator to interpolate $userName:
>
> unlink("..\\images\\users\\$userName\\".$_POST['images']);
>
> --
> David Powers
> Adobe Community Expert
> Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
> http://foundationphp.com/


Inspiring
September 5, 2006
OK - different tack.

This markup -

<?php
$string='..\\images\\users\\Murray\\ed.jpg';
echo($string."\n\r");
echo(is_file($string)?'File exists':'File doesn\'t exist');
unlink($string);
?>

Gives this output -

..\images\users\Murray\ed.jpg File exists
Warning: unlink(..\images\users\Murray\ed.jpg) [function.unlink]: Permission
denied in
W:\Webspace\resadmin\madison\madisonconcrete.com\www\manage\x-unlink.php on
line 13

Gah....


--
Murray --- ICQ 71997575
Adobe Community Expert
(If you *MUST* email me, don't LAUGH when you do so!)
==================
http://www.dreamweavermx-templates.com - Template Triage!
http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
http://www.dwfaq.com - DW FAQs, Tutorials & Resources
http://www.macromedia.com/support/search/ - Macromedia (MM) Technotes
==================


"David Powers" <david@example.com> wrote in message
news:edk19s$sn9$1@forums.macromedia.com...
> Murray *ACE* wrote:
>> unlink("..\\images\\users\\".$userName."\\".$_POST['images']);
>>
>> That line (line 82) gives me this error -
>>
>> Parse error: parse error, unexpected T_STRING
>
> It may not solve your problem, but you don't need to use the concatenation
> operator to interpolate $userName:
>
> unlink("..\\images\\users\\$userName\\".$_POST['images']);
>
> --
> David Powers
> Adobe Community Expert
> Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
> http://foundationphp.com/


Inspiring
September 5, 2006
Murray *ACE* wrote:
> unlink("..\\images\\users\\".$userName."\\".$_POST['images']);
>
> That line (line 82) gives me this error -
>
> Parse error: parse error, unexpected T_STRING

It may not solve your problem, but you don't need to use the
concatenation operator to interpolate $userName:

unlink("..\\images\\users\\$userName\\".$_POST['images']);

--
David Powers
Adobe Community Expert
Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
http://foundationphp.com/
Inspiring
September 5, 2006
I guess there is something I'm just not getting here -

unlink("..\\images\\users\\".$userName."\\".$_POST['images']);

That line (line 82) gives me this error -

Parse error: parse error, unexpected T_STRING in
W:\Webspace\resadmin\madison\madisonconcrete.com\www\manage\m_users_update.php
on line 82



--
Murray --- ICQ 71997575
Adobe Community Expert
(If you *MUST* email me, don't LAUGH when you do so!)
==================
http://www.dreamweavermx-templates.com - Template Triage!
http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
http://www.dwfaq.com - DW FAQs, Tutorials & Resources
http://www.macromedia.com/support/search/ - Macromedia (MM) Technotes
==================


"Joe Makowiec" <makowiec@invalid.invalid> wrote in message
news:Xns983562C871DE1makowiecatnycapdotrE@216.104.212.96...
> On 05 Sep 2006 in macromedia.dreamweaver.appdev, Murray *ACE* wrote:
>
>> As discussed on the PHP.Net site, I am throwing a permission denied
>> error -
>>
>> Warning: unlink(../images/users/Murray/Creek.jpg) [function.unlink]:
>> Permission denied in
>> W:\Webspace\resadmin\madison\madisonconcrete.com\www\manage\m_users_u
>> pdate.php on line 82
>>
>>
>> when I try to delete an image file from a folder with this markup -
>>
>> unlink('../images/users/'.$userName."/".$_POST['images']);
>>
>> There are several vague workarounds there that I'm not sure I fully
>> followed. One of them says to make an ftp connection and then use
>> ftp delete to wipe the file. Is this the best way?
>
> Are you running into the same slash/backslash issue you ran into with
> your mkdir() issue?
>
> --
> Joe Makowiec
> http://makowiec.net/
> Email: http://makowiec.net/email.php


Inspiring
September 5, 2006
Hmm - I'll check....

--
Murray --- ICQ 71997575
Adobe Community Expert
(If you *MUST* email me, don't LAUGH when you do so!)
==================
http://www.dreamweavermx-templates.com - Template Triage!
http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
http://www.dwfaq.com - DW FAQs, Tutorials & Resources
http://www.macromedia.com/support/search/ - Macromedia (MM) Technotes
==================


"Joe Makowiec" <makowiec@invalid.invalid> wrote in message
news:Xns983562C871DE1makowiecatnycapdotrE@216.104.212.96...
> On 05 Sep 2006 in macromedia.dreamweaver.appdev, Murray *ACE* wrote:
>
>> As discussed on the PHP.Net site, I am throwing a permission denied
>> error -
>>
>> Warning: unlink(../images/users/Murray/Creek.jpg) [function.unlink]:
>> Permission denied in
>> W:\Webspace\resadmin\madison\madisonconcrete.com\www\manage\m_users_u
>> pdate.php on line 82
>>
>>
>> when I try to delete an image file from a folder with this markup -
>>
>> unlink('../images/users/'.$userName."/".$_POST['images']);
>>
>> There are several vague workarounds there that I'm not sure I fully
>> followed. One of them says to make an ftp connection and then use
>> ftp delete to wipe the file. Is this the best way?
>
> Are you running into the same slash/backslash issue you ran into with
> your mkdir() issue?
>
> --
> Joe Makowiec
> http://makowiec.net/
> Email: http://makowiec.net/email.php


Inspiring
September 5, 2006
On 05 Sep 2006 in macromedia.dreamweaver.appdev, Murray *ACE* wrote:

> As discussed on the PHP.Net site, I am throwing a permission denied
> error -
>
> Warning: unlink(../images/users/Murray/Creek.jpg) [function.unlink]:
> Permission denied in
> W:\Webspace\resadmin\madison\madisonconcrete.com\www\manage\m_users_u
> pdate.php on line 82
>
>
> when I try to delete an image file from a folder with this markup -
>
> unlink('../images/users/'.$userName."/".$_POST['images']);
>
> There are several vague workarounds there that I'm not sure I fully
> followed. One of them says to make an ftp connection and then use
> ftp delete to wipe the file. Is this the best way?

Are you running into the same slash/backslash issue you ran into with
your mkdir() issue?

--
Joe Makowiec
http://makowiec.net/
Email: http://makowiec.net/email.php