Hello!
I'm trying to upload image files using the UnityWebRequest class.
My code looks like this:
//get image
var imageData = _sprite.texture.GetRawTextureData();
var data = new List {
new MultipartFormDataSection("foo", "bar"),
new MultipartFormFileSection("myImage", imageData, "test.png", "image/png")
};
//init handshake
var handshake = UnityWebRequest.Post("http://mypage/uload.php", data);
var request = handshake.SendWebRequest();
//response
request.completed += (action) => {
if (!handshake.isHttpError && !handshake.isNetworkError) {
Debug.Log(handshake.downloadHandler.text);
}
};
The response looks like this:
Array (
[myImage] => Array
(
[name] => test.png
[type] =>
[tmp_name] =>
[error] => 3
[size] => 0
) )
Does anyone have an idea what i'm doing wrong?
↧