Forum

Image upload with node http (network post)


#1

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:

  1. Open a picture file in a FileTexture(EX9.Texture) node.
  2. Texture Out to a AsRaw(EX9.Texture) node. Set pin FileFormat to PNG.
  3. AsRaw output to Encode (String Base64) node.
  4. 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.


HTTP (Network Post) to upload image?
Image upload with node http (network post)
Post Jpeg via HTTP (post)
#2

see also: