PHP使用API​​将文件发送到PYTHON,反之亦然

时间:2016-05-10 05:21:11

标签: php python api

我是API,PHP和PYTHON的新手。我试图通过API连接我的PHP和PYTHON脚本,直到现在我尝试过:

PHP script to choose file:
<form enctype="multipart/form-data" action="uploader.php" method="POST">
<font color="#330033">Choose a file to upload: </font>
<input id="uploadedfile" name="uploadedfile" type="file" accept="text/plain"/><br />
<input type="submit" value="Upload File" />
</form>

uploader PHP script : uploader.php :

$target_path = $_FILES['uploadedfile']['name'];

$output = shell_exec("python Demo.py $target_path $r");

That executes the python script by submiting the user chosen text file info.

Demo.py

with open(sys.argv[1]) as f: to receive the file and do the desired action.

现在我想通过API发送文件,从PHP文件中添加对python脚本的API调用,python脚本应该通过API接收文件并通过API再次发回。

我被困住了,不知道如何继续。请帮忙。

0 个答案:

没有答案