I uploaded an image file and copied it from temporary folder to a folder inside /var/www/. Then, tried to execute a python command via php where the exec() command is i
In the python script file, the directory change was done as
os.chdir('/var/www/upload')
and in the php side, I gave the full path for the python script to run
exec('python /var/www/upload/script.py ' . $_FILES["file"]["name"]);
This way, the problem got solved.