M Masoud44 Member May 30, 2024 #1 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 [CODE lang="b4x" title="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)[/CODE] [CODE lang="b4x" title="concat"]Sub concat(vname as byte,image as byte) as byte dim c as byte c=vname+image ?????????? return c End Sub[/CODE]
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 [CODE lang="b4x" title="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)[/CODE] [CODE lang="b4x" title="concat"]Sub concat(vname as byte,image as byte) as byte dim c as byte c=vname+image ?????????? return c End Sub[/CODE]
Solution teddybear Jun 3, 2024 Masoud44 said: I congratulate you very well. Please upload it along with the php code. Click to expand... 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 said: I congratulate you very well. Please upload it along with the php code. Click to expand... 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); ?>
M Masoud44 Member Jun 3, 2024 #21 teddybear said: 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); ?> Click to expand... It's perfect , thank you so much Upvote 0
teddybear said: 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); ?> Click to expand... It's perfect , thank you so much