[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now


PHP Rename Permission Denied - Error Handlng

Posted on 2007-08-12
Medium Priority
Last Modified: 2013-11-05
My website maintains a database along with a set of folders on my server.  The Syncronization between these is working fine.  By this I mean if you add a record to the table a folder is created with the same name, if you rename the record the folder is renamed to the new name etc etc.

The problem i am having is that becuase we run a Windows 2003 server and remote desktop onto it to do various other file management tasks to the contents within these folders created by the website you can provoke a Permission Denied error on the website by accidently having a file open within a folder that PHP wishes to rename!

I understand that this is what should happen as the results are the same within Windows but instead of my website just keeling over with an error message i would like to pop up a message saying "Folder in use : rename not possible, try again later...." or something along those lines?

I have tried :

if (!rename($old_folder, $new_folder)) .....

But this does not work...

Is there another way around this?
Question by:Sailo100
  • 3

Assisted Solution

deresh earned 1000 total points
ID: 19679087
you could try:

if(FALSE === rename($old_folder,$new_folder))
// do something if rename failed
echo "Folder in use : rename not possible, try again later....";


Author Comment

ID: 19679093
What does 3 equal signs mean?

Author Comment

ID: 19679137
This does not appear to work....  I still get permission denied?
LVL 15

Accepted Solution

m1tk4 earned 1000 total points
ID: 19679400
add a @ to rename call in the sample above to suppress the error message:


=== in PHP means "equal and the type is the same". For example:

(FALSE == 0 ) is TRUE
(FALSE === 0) is FALSE


Author Comment

ID: 19679442
Perfect thanks guys!  I've always wanted to know what @ was used for :-)

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

These days socially coordinated efforts have turned into a critical requirement for enterprises.
It’s a season to be thankful, and we’re thankful for users like you who engage on site, solve technology problems, and network with others in the industry. What tech are we most thankful for? Keep reading.
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
Suggested Courses
Course of the Month18 days, 23 hours left to enroll

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question