Send image with python, save with php

Various r ... I'll write it down because it seems to be useful for interesting things

pic_post.py


import requests
#This sender → put it locally
with open("img.jpg ", "rb") as f:#Open image(Like reading?)To do
	url='http://hogehoge.jp/pic_save.php'#Destination
	r = requests.post(url, f.read())#Send

pic_save.php


<?php
//This is on the receiving side → on the server side
	$bin = file_get_contents("php://input");//Take out the received item
	file_put_contents('./img.jpg',$bin);//In the same directory, "img.Save with the file name "jpg"
?>

For the time being, it should work with the above code I may add what the meaning of f.read () is If the extension is different (png, gif) or if you want to select an image, you really want to think about it

reference

[PHP] Download the image and save it in a specific directory on the server http://codaholic.org/?p=341

Recommended Posts

Send image with python, save with php
HTML email with image to send with python
Image processing with Python
Send email with Python
Image processing with Python (Part 2)
Send Japanese email with Python3
Image editing with python OpenCV
Sorting image files with Python (2)
Sorting image files with Python (3)
Image processing with Python (Part 1)
Tweet with image in Python
Sorting image files with Python
Image processing with Python (Part 3)
Send using Python with Gmail
[Python] Image processing with scikit-image
[Python] Send gmail with python: Send one by one with multiple image files attached
Cut out an image with python
[Python] Using OpenCV with Python (Image transformation)
Dynamic proxy with python, ruby, PHP
[Automation] Send Outlook email with Python
Image processing with Python 100 knocks # 3 Binarization
Let's do image scraping with Python
Find image similarity with Python + OpenCV
Image processing with Python 100 knocks # 2 Grayscale
[Python] Send an email with outlook
Handling regular expressions with PHP / Python
Send multipart / form-data with python requests
Send email via gmail with Python 3.4.3.
Gradation image generation with Python [1] | np.linspace
Basics of binarized image processing with Python
Image processing with Python 100 knock # 10 median filter
Realize PHP / Python generator with Golang / Ruby
Create a dummy image with Python + PIL.
Save video frame by frame with Python OpenCV
Image processing with Python 100 knocks # 8 Max pooling
Introduction to Python Image Inflating Image inflating with ImageDataGenerator
Save / load in-memory DB with python sqlite3
Use cryptography library cryptography with Docker Python image
Image processing with Python & OpenCV [Tone Curve]
Image processing with Python 100 knock # 12 motion filter
Image acquisition from camera with Python + OpenCV
Record with Python → Save file (sounddevice + wave)
Drawing with Matrix-Reinventor of Python Image Processing-
Easy image processing in Python with Pillow
Image processing with Python 100 knocks # 7 Average pooling
Send an email with Amazon SES + Python
Light image processing with Python x OpenCV
Image processing with Python 100 knocks # 9 Gaussian filter
Sample to convert image to Wavelet with Python
FizzBuzz with Python3
Scraping with Python
python image processing
Scraping with Python
Python with Go
[Python] Send email
Twilio with Python
Integrate with Python
Play with 2016-Python
AES256 with python
Tested with Python
[Python] Send email