在我的Django API中,我生成了一个PDF文件。我想向一个PHP文件发送一个请求,该文件处理上传以上传该文件。以下是我写的:
我还尝试了以下方法在我的Django API中,我生成了一个PDF文件。我想向一个PHP文件发送一个请求,该文件处理上传以上传该文件。以下是我写的:,php,api,file-upload,request,Php,Api,File Upload,Request,我还尝试了以下方法 url = 'url.to.the.php.file.which.handles.upload' files = { file: ('file_name', open('file/path', 'rb')) } response = requests.post(url, files=files) 并尝试将“文件”更改为“数据”,如下所示 url = 'url.to.the.php.file.which.handles.upload' files = { name
url = 'url.to.the.php.file.which.handles.upload'
files = {
file: ('file_name', open('file/path', 'rb'))
}
response = requests.post(url, files=files)
并尝试将“文件”更改为“数据”,如下所示
url = 'url.to.the.php.file.which.handles.upload'
files = {
name: 'file_name',
file: open('file/path', 'rb')
}
response = requests.post(url, files=files)
在PHP文件中,我有以下代码(如果有帮助的话)
我收到“内部服务器错误”或没有错误-但文件没有上载。您是否尝试过
files={'file':open('myfirstreact.png','rb')}
是的,这也不起作用
response = requests.post(url, data=data)
$filename = $_FILES['file']['name'];
$tempPath = $_FILES['file']['tmp_name'];
$file_no=substr($filename,0,10);