Hi everyone,
I have found few old posts (all closed) asking how to upload an image from vvvv to a server.
Here is a solution…
In VVVV:
- Open a picture file in a FileTexture(EX9.Texture) node.
- Texture Out to a AsRaw(EX9.Texture) node. Set pin FileFormat to PNG.
- AsRaw output to Encode (String Base64) node.
- Encode output to the pin value of HTTP (Network Post) node.
On the server side, here is a simple php code to save the picture (as PNG)
<?php
$img = $_POST['my_picture']('my_picture'); // Set in vvvv by pin 'Name' of HTTP (Network Post) node.
$sizeR = strlen($img);
if ($sizeR > 0) {
$img = str_replace('data:image/png;base64,', '', $img);
$img = str_replace(' ', '+', $img);
$data = base64_decode($img);
$size = file_put_contents('test.png',$data);
echo "File saved. " . $size . ' bytes';
}
else {
echo 'Choose a picture file.';
}
?>
Hope it helps.