Python send image using request
import requests
def uplaod_image_on_server(url,image_path):
# Open the image file in binary mode
with open(image_path, "rb") as file:
# Create a dictionary with the file parameter and the image file
files = {"screenshot": (image_path, file, "image/jpeg")}
# post data
payload = {
"SystemName": "DESKTOP112",
}
# Make the POST request with the image
response = requests.post(url, files=files,data=payload)
# Print the response
print(response.text)
uplaodImageUrl = "http://localhost/testing/"
image_path = "./image.png"
uplaod_image_on_server(uplaodImageUrl,image_path)
Comments
Post a Comment