Android Question concat two variable in byte

Masoud44

Member
Hi ...
Is it possible to concat two variables in bytes for php post (var name and var value).
Is it possible to use postbyte in this way? I used combine and join instead of concat, but it didn't work
post:
    Dim var As String="img="
    Dim bmp As Bitmap=ImageView1.Bitmap
    Dim i() As Byte = ImageToBytes(bmp)
    Dim vb() As Byte=var.GetBytes("UTF8")
    Dim data() As Byte = Concat(vb, i)    ' vb+i  such as & for concat two string
    Dim j As HttpJob
    j.Initialize("insertimg", Me) 'jobdon
    j.PostBytes(ServerIP & "insert.php", data)
concat:
Sub concat(vname as byte,image as byte) as byte
    dim c as byte
    c=vname+image ??????????
    return c
End Sub
 
Solution
I congratulate you very well.
Please upload it along with the php code.
B4X
B4X:
    Dim job As HttpJob
    job.Initialize("", Me)
    job.PostBytes("http://localhost/ch01/test.php", concat("img=".GetBytes("utf8"),File.ReadBytes(File.DirAssets,"image.jpg")))
PHP
PHP:
<?php

$rawPostData = file_get_contents('php://input');

$byteArray = substr($rawPostData,4);

file_put_contents("image.jpg",$byteArray);

echo "Received byte data length: " . strlen((String)$byteArray);
?>

Masoud44

Member
It's perfect , thank you so much
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…