I am trying to upload image on DirectAdmin (wordpress upload path) using python request. DA responses with 200 status code but its not working.
here is my code:
and this is response:
here is my code:
Python:
import requests
from requests.auth import HTTPBasicAuth
from datetime import datetime
site = '####'
username = '####'
password = '####'
current_year = datetime.now().strftime('%Y')
current_month = datetime.now().strftime('%m')
url = f'https://{site}:2222/CMD_FILE_MANAGER/domains/{site}/public_html/wp-content/uploads/{current_year}/{current_month}'
auth = HTTPBasicAuth(username, password)
headers = {
'Content-Type': 'multipart/form-data;',
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.0.0 Safari/537.36'
}
filename = 'test.jpg'
file = {'file': (filename, open(filename, 'rb'))}
r = requests.post(creation_url, files=file, headers=headers, auth=auth)
print(r.status_code)
print(r.headers)
and this is response:
Code:
200
<!DOCTYPE html>
<html>
<head>
<base href=/evo/fm/>
<title> blackwalnut.ir | DirectAdmin 1.646 </title>
<meta charset=utf-8>
<meta name=description content="New generation filemanager for DirectAdmin">
<meta name=format-detection content="telephone=no">
<meta name=msapplication-tap-highlight content=no>
<meta name=viewport content="user-scalable=no,initial-scale=1,maximum-scale=1,minimum-scale=1,width=device-width">
<link rel=icon type=image/svg
href=data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4KPCEtLSBHZW5lcmF0b3I6IEFkb2JlIElsbHVzdHJhdG9yIDIxLjAuMCwgU1ZHIEV4cG9ydCBQbHVnLUluIC4gU1ZHIFZlcnNpb246IDYuMDAgQnVpbGQgMCkgIC0tPgo8c3ZnIHZlcnNpb249IjEuMSIgaWQ9IkxheWVyXzEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIHg9IjBweCIgeT0iMHB4IgoJIHZpZXdCb3g9IjAgMCA4OCAxMDIuMiIgc3R5bGU9ImVuYWJsZS1iYWNrZ3JvdW5kOm5ldyAwIDAgODggMTAyLjI7IiB4bWw6c3BhY2U9InByZXNlcnZlIj4KPHN0eWxlIHR5cGU9InRleHQvY3NzIj4KCS5zdDB7ZmlsbDojMDY4MkI0O30KCS5zdDF7ZmlsbDojMzFCN0U5O30KCS5zdDJ7ZmlsbDpub25lO30KPC9zdHlsZT4KPGc+Cgk8Zz4KCQk8Zz4KCQkJPHBvbHlnb24gY2xhc3M9InN0MCIgcG9pbnRzPSI4OCw1Mi42IDg4LDUyLjYgMzguNCwzIDI0LjIsMTcuMiA1OS43LDUyLjYgMjQuMyw4OCAzOC40LDEwMi4yIAkJCSIvPgoJCTwvZz4KCQk8Zz4KCQkJPHBvbHlnb24gY2xhc3M9InN0MSIgcG9pbnRzPSI4NSw0OS42IDg1LDQ5LjYgMzUuNCwwIDIxLjIsMTQuMiA1Ni43LDQ5LjYgMjEuMyw4NSAzNS40LDk5LjIgCQkJIi8+CgkJPC9nPgoJPC9nPgoJPGxpbmUgY2xhc3M9InN0MiIgeDE9IjQwLjMiIHkxPSIxMDMuOCIgeDI9IjkwLjEiIHkyPSI1NC4yIi8+Cgk8Zz4KCQk8cG9seWxpbmUgY2xhc3M9InN0MCIgcG9pbnRzPSIxMC41LDc0LjQgMTQuMSw3OCA0Mi40LDQ5LjYgMzguNyw0NS44IAkJIi8+CgkJPHBvbHlsaW5lIGNsYXNzPSJzdDEiIHBvaW50cz0iMzguNyw0NS45IDE0LjIsMjEuMyAwLDM1LjQgMTQuMiw0OS42IDAsNjMuOCAxMC42LDc0LjQgCQkiLz4KCTwvZz4KPC9nPgo8L3N2Zz4K>
<link href=/evo/fm/css/filemanager.43a52b9675a99489aeb3.css rel=stylesheet>
</head>
<body>
<div id=q-app></div>
<script src=/evo/fm/vendor.b62776ea3ba9b15510da.js></script>
<script src=/evo/fm/filemanager.b62776ea3ba9b15510da.js></script>
<script src=/evo/fm/runtime.b62776ea3ba9b15510da.js></script>
</body>
</html>