You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The data is there printed in the console, so that part works, but the data must be decoded. Does SimpleHTTPServer come with any helper functions for this?
A nice Example for this feature would be a tiny image gallery. Allow uploading images, and then show them as thumbnails in the html. Maybe convert them to black and white in Processing before saving them :)
I think there would be some things todo in the DynamicResponseHandler, which tells it that the method is post with content-type: multipart/form-data. The Handler (SHTTPSHandler) uses com.sun.net.httpserver.HttpExchange, for which I couldn't find anything that does that.
only the head can be derived like this, which could be the beginning:
DynamicResponseHandler responder1;
void setup() {
SimpleHTTPServer.useIndexHtml = false;
server = new SimpleHTTPServer(this);
TemplateFileHandler templateHandler = new ResultFromPost("index.ftl");
server.createContext("", templateHandler);
responder1 = new DynamicResponseHandler(new FileUpload(), "application/json");
server.createContext("upload", responder1);
}
class FileUpload extends ResponseBuilder {
public String getResponse(String requestBody) {
//println(requestBody.split("\n")[0]);
println(parent.getExchange().getRequestHeaders().values());
return "";
}
}
Hi! :) I was wondering if it's possible to upload files to the server?
I tried this:
And this is the ftl
The data is there printed in the console, so that part works, but the data must be decoded. Does SimpleHTTPServer come with any helper functions for this?
A nice Example for this feature would be a tiny image gallery. Allow uploading images, and then show them as thumbnails in the html. Maybe convert them to black and white in Processing before saving them :)
Here some info about the decoding part:
https://stackoverflow.com/questions/3337056/convenient-way-to-parse-incoming-multipart-form-data-parameters-in-a-servlet
The text was updated successfully, but these errors were encountered: