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

Popular posts from this blog

Ensuring File Creation in the Current Directory when Converting Python (.py) Script to Executable (.exe).

Express Production Setup - 4 | HELMET

Node Js Private Key And Public Key Encryption and Decryption