For certain interactive installations (like the Sky Radio Photo booth) I need to be able to save and upload images to a webserver. There are different examples in the Processing forum, but not one clear and easy solution.
Actually the code is largely based on my Processing Azure Face API code, however instead of sending the image to Microsoft Azure, the image is uploaded to a web server and stored with PHP. Like the Azure example this code uses the Apache HTTP client library (from the Apache HTTPComponents project). It’s already included in the sketch folder, so you don’t have to download or install it separately.
Web Server configuration
First make sure you have a host that supports PHP.
Create a folder called “processing_upload” on the location you want (or modify the $targetDir variable in saveImage.php). Place saveImage.php in the same folder as you’ve placed the processing_upload folder (pay attention don’t place saveImage.php within processing_upload).
Don’t forget to set the file permissions of the folder to write (755).
Modify the Processing sketch
In the Processing sketch you have to point the
(in ImageUploader.pde) to the folder on your own server where you saved the saveImage.php file.
- JPEG compression sketch by Jeff Thompson.
- Multipart uploader example by Eugen Paraschiv (Baeldung).
- PHP saveImage file from W3Schools.
- Apache HTTPClient binary.
Was this article useful to you? Buy me a coffee!