Run the PHP file through the browser to call the Python script code does not execute?

under Windows, PHP calls python, to run PHP files through the browser, but calls Python"s video playback function. What"s going on?

video.php file

$shell = shell_exec ("test.py");

test.py file

from os import startfile

startfile ("a.avi");

run php video.php under the CMD command to call the local default player to open the video

but I don"t respond when I use the browser localhost/test/video.php. What"s going on

Sep.16,2021

permission problem? The role of executing the script when browsing the web is www-data or the


that you configure yourself.

should be the execution directory (the reason for the working directory) when), PHP is called, it becomes the current PHP directory. So change the working directory, or set the path of the file opened by py to an absolute path.

< H1 > change the work path < / H1 >

import os
os.chdir

< H1 > View the path to the py execution file < / H1 >

import sys
print (sys.argv [0])

< H1 > View current work path < / H1 >

import os
print (os.getcwd ())

Menu