usually, when trying to move files around on your server, the script will need permission to write any locations where files are to be placed. this can in some cases mean apache (which will have different user ids on different systems). some scripts don't run via apache (e.g., via cron or command-line) and the user running them will need the permission.
It's usually a good idea to check with is_writable or is_readable or other such functions before trying to move a file and, if you can't read/write the location in question, then you can output a more specific error so you know what the real problem is. it takes more time to write the code, but that usually pays off when you try to implement the script because it saves you from wondering what went wrong.