there is my code: client:
def upload(url,file):
file_name=file.split('\\')[-1]
with open(file,'rb') as f:
r=requests.post(url,data=f)
server side:
$datastr = fopen('php://input',"rb");
$filename='upload/111.bin';
if ($fp = fopen($filename,"wb")){
while(!feof($datastr)){
fwrite($fp,fread($datastr,4096)) ;
}
}
it can work, but I don't know how to post the file stream with file name.
if I use r=requests.post(url,data={ 'name':file_name, 'file':open(file,'rb') }), $_POST is null
with open(file,'rb') as f: r=requests.post(url,data=f)but I don't know how to post the stream with file name.