通过API发送(使用Python)和接收(使用PHP)文件
如何通过api发送和接收文件。我想通过APi发送和接收pdf和图像文件。我怎样才能做到?例如,用户使用python发送文件(使用python进行API调用),我在端点(使用PHP)接收文件并将其保存到文件系统。如何通过API发送和接收文件 API端点仅接受application/json 当有人通过API(用python编写)向我发送文件时,我如何使用PHP处理该文件 以下是我迄今为止的解决方案: Base64在python端对文件进行编码 然后在PHP端对文件进行解码 问题是我不知道如何通过解码来检索文件 有人知道如何解码文件并将其内容保存到数据库吗?您必须使用通过API发送(使用Python)和接收(使用PHP)文件,php,jquery,python,api,Php,Jquery,Python,Api,如何通过api发送和接收文件。我想通过APi发送和接收pdf和图像文件。我怎样才能做到?例如,用户使用python发送文件(使用python进行API调用),我在端点(使用PHP)接收文件并将其保存到文件系统。如何通过API发送和接收文件 API端点仅接受application/json 当有人通过API(用python编写)向我发送文件时,我如何使用PHP处理该文件 以下是我迄今为止的解决方案: Base64在python端对文件进行编码 然后在PHP端对文件进行解码 问题是我不知道如何通过解
这可能会对您有所帮助我不确定,因为我不喜欢PHPI我正在尝试用python而不是JQueryId做这件事您尝试使用“move_uploaded_file()”并使用$_POST['file']或$_FILES['file']获取文件数据?你有什么错误吗?
<form enctype="multipart/form-data" method="post" name="fileinfo">
<label>Your email address:</label>
<input type="email" autocomplete="on" autofocus name="userid" placeholder="email" required size="32" maxlength="64" /><br />
<label>Custom file label:</label>
<input type="text" name="filelabel" size="12" maxlength="32" /><br />
<label>File to stash:</label>
<input type="file" name="file" required />
<input type="submit" value="Stash the file!" />
</form>
<div></div>
var fd = new FormData(document.querySelector("form"));
fd.append("CustomField", "This is some extra data");
$.ajax({
url: "stash.php",
type: "POST",
data: fd,
processData: false, // tell jQuery not to process the data
contentType: false // tell jQuery not to set contentType
});