Hi everyone...I getting no where with the application I'm working. I'm trying to upload image to the server but failed to do so. Kindly check my codes below.
ImageToSave is the variable that holds the converted image
The next block of code is sending to the server
The total length of ImageToSave is 1957536 and I'm getting a "414 Request-URI Too long". I read from forum that with this kind of case it is best to use POST. Can any one help me point in the right direction how to resolve my trouble?
Best regards,
microbox
ImageToSave is the variable that holds the converted image
B4X:
Sub Camera1_PictureTaken (Data() As Byte)
camera1.StartPreview
'-------------------------------------------------------------
Dim fileName,pma,pmb As String
DateTime.DateFormat = "yyyy-MM-dd"
pma = DateTime.Date(DateTime.Now)
DateTime.TimeFormat = "HH:mm"
pmb = DateTime.Time(DateTime.Now)
fileName = "Photo_" & TransId & pma &"_" & pmb
Try
'------------------------------------------------------------
Dim out As OutputStream
out = File.OpenOutput(File.DirRootExternal & "/" & AppFolder, fileName & ".jpg", False)
out.WriteBytes(Data, 0, Data.Length)
out.Close
Dim im As Bitmap
im.Initialize(File.DirRootExternal & "/" & AppFolder,fileName & ".jpg")
imgphoto.SetBackgroundImage(LoadBitmap(File.DirRootExternal & "/" & AppFolder,fileName & ".jpg"))
Log("Image saved: " & File.Combine(File.DirRootExternal & "/" & AppFolder, fileName & ".jpg"))
File1 = File.DirRootExternal & "/" & AppFolder
File2 = fileName & ".jpg"
btnCamera.Enabled = True
Dim bytes() As Byte = ImageToBytes(im)
Dim B64 As Base64
ImageToSave=""
ImageToSave = B64.EncodeBtoS(bytes,0,bytes.Length-1)
Log(ImageToSave.Length)
Catch
Log("Camera error")
End Try
End Sub
The next block of code is sending to the server
B4X:
Sub btnsendImages_Click
Dim loginServer As HttpJob
loginServer.Initialize("SubmitImage",Me)
loginServer.Download2("http://" & ServerIP, Array As String("action","SubmitImage","photo",ImageToSave,"rep_id",Rep_Id))
End Sub
Best regards,
microbox