![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | monkeyTester |
![]() |
Old Version | Published before Godot 3 was released. |
How would you upload an image to a server using HttpClient. What i have so far is below.
var r=RawArray()
r.append("----WebKitFormBoundaryePkpFF7tjBAqx29L\n")
r.append("Content-Disposition: form-data; name=\"imgFile\"; filename=\"cube.png\"\n")
r.append("Content-Type: image/png\n")
r.append("\n")
var file = File.new()
file.open("res://Template/cube.png", file.READ)
var content = file.get_buffer(file.get_len())
file.close()
r.append_array(content)
r.append("----WebKitFormBoundaryePkpFF7tjBAqx29L")
var headers=[
"Content-Length: "+String(content.size()),
"Content-Type: multipart/form-data, boundary=----WebKitFormBoundaryePkpFF7tjBAqx29L"
]
err=http.request_raw(HTTPClient.METHOD_POST,"/BloxPhp/MeshUpload.php",headers,r)
However this returns am empty array when print $POST. Is my approach correct?
Did you ever solve this? I’m looking into something similar and no luck yet.
namathos | 2020-06-17 17:34