PHP rename()file_exists()

How can I use PHP to move a file?

Code:

if( file_exists($imageLocation) )
  echo "file exists on server";

rename($imageLocation, $imageNewLocation);

Output:

file exists on server Warning: rename(/home/images/file1.jpg,/home/newloc/renamed.jpg) [function.rename]: No such file or directory in /home/apps/images/add.php on line 81

I don't know where to go from here.

When moving files, rename() can only move them to a folder that already exists. It can not create new parent directories on the fly.

Make sure /home/newloc exists. If it doesn't, use mkdir() to create it.