Android Question postfile error

nickysuwandi

Member
Licensed User
Longtime User
Dear All

Try to using posfile for upload image to server, i get error , did anyone know what the error?

(Exception) java.lang.Exception: java.io.FileNotFoundException: /data/user/0/anywheresoftware.b4a.samples.signaturecapture/cache/1: open failed: ENOENT (No such file or directory)

when check file using File.Exists, the file is found,

Thanks


[CODE lang="b4x" title="code"]Sub UploadSignSales(strfld As String) As ResumableSub
ProgressDialogShow2("wait,Upload Sign...",True )
Dim strhasil As String
Try
Dim job As HttpJob
job.Initialize("UploadFileSignSales" , Me)
Dim S As String = "http://192.168.5.80:54340/v1.0/FileUploading/UploadFileSignSales"

job.PostFile(S ,strfld , "sign=202305.jpg")
'job.GetRequest.SetContentType("application/form-data")
wait for (job) JobDone (job As HttpJob)
job.Release
Catch
Log(LastException)
End Try
ProgressDialogHide
Return strhasil
End Sub[/CODE]
 
B4X:
job.PostFile(Link As String, Dir As String, FileName As String)

You are passing wrong value to the function. Try:
B4X:
Dim S As String = "http://192.168.5.80:54340/v1.0/FileUploading/UploadFileSignSales?sign=202305.jpg"
job.PostFile(S, Dir, "202305.jpg")

* Dir is the directory of the file
 
Upvote 0
B4X:
job.PostFile(Link As String, Dir As String, FileName As String)

You are passing wrong value to the function. Try:
B4X:
Dim S As String = "http://192.168.5.80:54340/v1.0/FileUploading/UploadFileSignSales?sign=202305.jpg"
job.PostFile(S, Dir, "202305.jpg")

* Dir is the directory of the file
Thanks aeric

i got another error

<BODY><h2>Bad Request - Invalid Hostname</h2>
<hr><p>HTTP Error 400. The request hostname is invalid.</p>
 
Upvote 0
Back
Top