slash197
slash197

Reputation: 9034

xmlhttprequest and php

Here's a stupid question, don't laugh, I've been trying to figure this out but no luck, I guess I'm too tired. So there's an application sending data (image file as string) to a php script, sending it with XMLHttpRequest.send(data). My question is how do I access this string in PHP to save it to a file?

EDIT $_POST, $_GET and $_FILES are all empty

Upvotes: 0

Views: 565

Answers (1)

Quentin
Quentin

Reputation: 943152

First: Make sure you are sending a POST request (when you call the open method)

Second: Since it looks like you are sending raw data, set an appropriate content type (with setRequestHeader)

Third: You should be able to retrieve the data with $HTTP_RAW_POST_DATA or file_get_contents("php://input");.

Upvotes: 1

Related Questions