Move uploaded file problem

Today I faced a new problem in php coding. I was coding a simple file uploader class. I used regular script as I do. A warning is found at move_uploaded_file() function. I passed some time googling about it. I found that the function cannot access the directory I have mentioned. I made a command on the bash shell, ls -l, and saw that only the root user have the writing permission on that directory. That is why a client cannot upload file using that script. I againg made a command on the bash shell sudo chmod +w folder. ThenĀ  the script run correctly.

I saw another porblem about the directory. If you use ../ in the directory path, the returned path is path of immediate parent of the current folder. But ../../ is not accepted. So to go two or more step beyond the current directory you need to get the destination path name manually. getcwd() returns current working directory. A way to find the directory path of the current script is to use dirname(__FILE__). Once you find the directory path, now you can edit it to go two or more step beyond.

Tags:, , , ,

This entry was posted on Thursday, February 11th, 2010 at 7:14 pm and is filed under PHP, University life.

You can follow any responses to this entry through the RSS 2.0 feed.

You can leave a response, or trackback from your own site.

Leave a Reply