Hi.
how to upload an image from my pc?
c.write("<img src=1.jpg>");
import processing.net.*;
String HTTP_GET_REQUEST = "GET /";
String HTTP_HEADER = "HTTP/1.0 200 OK\r\nContent-Type: text/html\r\n\r\n";
Server s;
Client c;
String input;
PImage img; // Declare variable "a" of type PImage
void setup()
{
s = new Server(this, 8080,"192.168.1.9"); // start server on http-alt
img = loadImage("1.jpg"); // Load the image into the program
}
void draw()
{ image(img, 0, 0);
// Receive data from client
c = s.available();
if (c != null) {
input = c.readString();
input = input.substring(0, input.indexOf("\n")); // Only up to the newline
if (input.indexOf(HTTP_GET_REQUEST) == 0) // starts with ...
{
c.write(HTTP_HEADER); // answer that we're ok with the request and are gonna send html
// some html
c.write("<html><head><title>Processing talkin'</title></head><body><h3>Your base are belong to us!");
c.write("<img src=1.jpg>");
c.write("</h3></body></html>");
// close connection to client, otherwise it's gonna wait forever
c.stop();
}
}
}