DazChong
DazChong

Reputation: 23

PHP rename directory failed

Well my PHP script generated an error with a hyperlink in it.
Does anyone know what's wrong?

PHP Warning: rename(./uploads/temp/00013/,./uploads/orders/39/) [<a href='function.rename'>function.rename</a>]: No such file or directory

update:

actual code in PHP

          if(!file_exists('uploads/orders/')) {
                mkdir('uploads/orders/'); // ensuring the orders folder exist
            }
            rename('uploads/temp/' . $u . '/', 'uploads/orders/' . $i . '/');

update:

Sorry, my fault. I coded to delete previous temp folder before this code execute. Thanks!

Upvotes: 2

Views: 4042

Answers (2)

Joni
Joni

Reputation: 111249

When a computer tells you

No such file or directory

the first thing you should check is if the file/directory exists. This is not a random error message, it's given only in the specific situation when a file or directory you try to use does not exist.

In this case in particular, both ./uploads/temp/00013/ and ./uploads/orders/ have to exist. If orders doesn't exist it's not created for you.

Upvotes: 1

adrien
adrien

Reputation: 4439

It seems that one (or both) of these directories don't exist:

  • uploads/temp/00013
  • uploads/orders/39

Have you checked that:

  • these directories exist?
  • Apache/PHP has permission to read/write in these directories?
  • Your current directory is really the parent directory of your "upload" directory?

Upvotes: 2

Related Questions