/    Sign up×
Community /Pin to ProfileBookmark

unlink(direcoties) on localhost

Hi all

My localhost refuses to delete (unlink) directories, only files. This is presumably because it doesn’t think it’s allowed to touch folders on my local machine. However, unlink(directory) works fine on a live web server.

Is there any way I can enable the deleting of directories on my local host, perhaps via the php.ini file? Is this even possible since local folders obviously don’t have CHMOD permissions?

Thanks in advance.

to post a comment
PHP

3 Comments(s)

Copy linkTweet thisAlerts:
@JonaMay 31.2004 — [font=arial]That's because your online server has a loosened install of PHP. When you install PHP on your localhost, its settings are more strict. You should always code according to the stricter PHP, for portability -- it may also decrease processing time, in some cases.[/font]

[i]From the PHP Manual at PHP.net[/i]

[b]unlink



(PHP 3, PHP 4 , PHP 5)

unlink -- Deletes a [i]file[/i]



[...]



See also [url=http://www.php.net/manual/en/function.rmdir.php]rmdir() [/url] for removing directories.[/b]
[/quote]


[font=arial]This means that the unlink() function is not for removing directories, it's for removing files; use rmdir() to remove directories.[/font]
Copy linkTweet thisAlerts:
@mityaauthorMay 31.2004 — Thanks for that! I'd searched for ages for a remove directory function (I knew there had to be one) but didn't see rmdir();
Copy linkTweet thisAlerts:
@JonaMay 31.2004 — [font=arial]No problem, happy to help. ? [/font]
×

Success!

Help @mitya spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.16,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...