If you've given 777 permissions, you may want to add some debug statements to your file manipulation code to make sure you're not running into relative file location issues.
None of the "file manipulation code" is relevant - if you're getting error 7, it means PHP couldn't write to the upload directory before it ever started executing any of your script.
@sandeept: I'm wondering if the 0777 (not to be confused with 777 decimals ) permissions were given on the directory that PHP is attempting to use. Have you done a phpinfo() to confirm that this directory is indeed where you expect it to be?
Yes, I have checked phpinfo and I have given 777 permissions on respeective directory. But, I am wondering if this issue is related to CentOS or AWS (Amazon cloud services). I have set up websites earlier on different hosting service like GoDaddy, DailyRazor etc. But, I never faced such issue.