+2 votes

How would you upload an image to a server using HttpClient. What i have so far is below.

var r=RawArray()
r.append("Content-Disposition: form-data; name=\"imgFile\"; filename=\"cube.png\"\n")
r.append("Content-Type: image/png\n")
var file = File.new()
file.open("res://Template/cube.png", file.READ)
var content = file.get_buffer(file.get_len())
var headers=[
   "Content-Length: "+String(content.size()),
   "Content-Type: multipart/form-data,  boundary=----WebKitFormBoundaryePkpFF7tjBAqx29L"

However this returns am empty array when print $POST. Is my approach correct?

in Engine by (19 points)

Did you ever solve this? I'm looking into something similar and no luck yet.

1 Answer

+1 vote

Assuming the server is PHP you need to the check $_FILES array

by (366 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.