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
Dim job As HttpJob
job.Initialize("", Me)
job.PostBytes("http://localhost/ch01/test.php", concat("img=".GetBytes("utf8"),File.ReadBytes(File.DirAssets,"image.jpg")))
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
concat:
Sub concat(vname as byte,image as byte) as byte
dim c as byte
c=vname+image ??????????
return c
End Sub
The vname and image should be byte array and it should return a byte array in sub concat
Do concat using ByteConverter library.
B4X:
Sub concat(vname() As Byte, image() As Byte) As Byte()
Dim c(vname.Length+image.Length) As Byte
Dim bc As ByteConverter
bc.ArrayCopy(vname, 0, c, 0, vname.Length)
bc.ArrayCopy(image,0, c, vname.Length, image.Length)
Return c
End Sub
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
The vname and image should be byte array and it should return a byte array in sub concat
Do concat using ByteConverter library.
B4X:
Sub concat(vname() As Byte, image() As Byte) As Byte()
Dim c(vname.Length+image.Length) As Byte
Dim bc As ByteConverter
bc.ArrayCopy(vname, 0, c, 0, vname.Length)
bc.ArrayCopy(image,0, c, vname.Length, image.Length)
Return c
End Sub
I hope that PHP itself will do this with the post command, and if it doesn't, I will try to it myself.
this is done in the code below, and in this case, PHP separates the variable name from the variable content with the post command
postbyte:
Dim data As String
Dim imageStr As String = BitmapToString(image)
data="img="&imageStr
Dim j As HttpJob
j.Initialize("insertimg", Me)
j.postbyte(ServerIP & "insert.php",data.GetBytes("UTF8"))
The vname and image should be byte array and it should return a byte array in sub concat
Do concat using ByteConverter library.
B4X:
Sub concat(vname() As Byte, image() As Byte) As Byte()
Dim c(vname.Length+image.Length) As Byte
Dim bc As ByteConverter
bc.ArrayCopy(vname, 0, c, 0, vname.Length)
bc.ArrayCopy(image,0, c, vname.Length, image.Length)
Return c
End Sub
Sub CombineBytes(arr1() As Byte, arr2() As Byte) As Byte()
Dim res(arr1.Length + arr2.Length) As Byte
Dim bc As ByteConverter 'ByteConverter library
bc.ArrayCopy(arr1, 0, res, 0, arr1.Length)
bc.ArrayCopy(arr2, 0, res, arr1.Length, arr2.Length)
Return res
End Sub
The post command in PHP recognizes the name of the variable, but the content of the variable is not the image byte.
Dim data As String
Dim imageStr As String = BitmapToString(image)
data="img="&imageStr
Dim j As HttpJob
j.Initialize("insertimg", Me)
j.postbyte(ServerIP & "insert.php",data.GetBytes("UTF8"))
I want to keep the smallest possible size of an image in the database, which means about thirty percent less than what happens in the above code.
lets me to say this way, when I use encodebase64 and decodebase64, there is no problem, but at in this way the size of the file increases, as a result, the speed of the application decreases. For this reason, I am trying to save the images in the database without using encode to occupy 30% less space in the database to increase the speed of reading and writing images.
lets me to say this way, when I use encodebase64 and decodebase64, there is no problem, but at in this way the size of the file increases, as a result, the speed of the application decreases. For this reason, I am trying to save the images in the database without using encode to occupy 30% less space in the database to increase the speed of reading and writing images.
Yes, I had seen and followed post #13, but I think it was related to uploading images to the server and saving the addresses of the files in the database.
If it is not like this, then I did not understand it.
Anyway, thank you for taking the time to answer.
Dim job As HttpJob
job.Initialize("", Me)
job.PostBytes("http://localhost/ch01/test.php", concat("img=".GetBytes("utf8"),File.ReadBytes(File.DirAssets,"image.jpg")))