Python Requests :: Как написать код PHP на стороне сервера? - PullRequest
0 голосов
/ 10 февраля 2019

Я не могу заставить модуль PYTHON REQUESTS работать с моей формой загрузки

//Checking the request 
 if($_SERVER['REQUEST_METHOD']=='POST'){

 //Getting the file 
 $file = $_FILES['upload_file']['tmp_name'];

 //Getting the name of the file 
 $name = $_FILES['upload_file']['name'];


 //Path to upload 
 $path = 'uploads/';

 //Storing the file to location
 move_uploaded_file($file,$path."/".$name);

 //displaying success message 
 echo 'success';
 }

выше было на стороне PHP, теперь внизу - python

url = 'http://my-url-to-above-file/index.php'
files = {'upload_file': open('1a.pdf', 'rb')}

r = requests.post(url, files=files)
r.text

Должно работать с параметром upload_file .Но он не работает с файлом и

...