![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | IuryBorges1993 |
extends Panel
var toogle;
# Called when the node enters the scene tree for the first time.
func _ready():
toogle=false;
t()
pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
#func _process(delta):
# pass
func t():
var http=HTTPClient.new()
http.connect_to_host("http://localhost",80)
var r=PoolByteArray()
r.append("----WebKitFormBoundaryePkpFF7tjBAqx29L\n")
r.append("Content-Disposition: form-data; name=\"fileToUpload\"; filename=\"c.png\"\n")
r.append("Content-Type: image/png\n")
r.append("\n")
var file = File.new()
file.open("res://img/c.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"
]
var result = http.request_raw(HTTPClient.METHOD_POST,"/teste/teste.php",headers,r)
while (http.get_status() == HTTPClient.STATUS_REQUESTING):
http.poll()
OS.delay_msec(500)
if http.get_status() != HTTPClient.STATUS_BODY and http.get_status() != HTTPClient.STATUS_CONNECTED:
return
if !http.has_response():
return
var rb=PoolByteArray()
while(http.get_status()==HTTPClient.STATUS_BODY):
http.poll()
var chunk = http.read_response_body_chunk() # Get a chunk
if chunk.size()==0:
OS.delay_usec(1000)
rb = rb + chunk # Append to read buffer
var text = rb.get_string_from_utf8()
print(text)
pass
func _on_TextureButton_pressed():
if toogle:
$ConteinerMenuH/menuH.visible=false;
toogle=false;
else:
$ConteinerMenuH/menuH.visible=true;
toogle=true;
pass # Replace with function body.
func _on_http_request_completed(result, response_code, headers, body):
print(body.get_string_from_utf8());
pass # Replace with function body.
Did you manage to resolve this?
namathos | 2020-06-19 14:41