Inviare Foto da Android a Webservice php [risolto]

Forum in Italiano NON ufficiale
Rispondi
marcov
Site Admin
Messaggi: 18
Iscritto il: mar nov 16, 2021 12:24 pm

Inviare Foto da Android a Webservice php [risolto]

Messaggio da marcov »

Ciao Ragazzi,

non riesco a inviare delle foto salvate in dispositvo Android( sia nella cartelle che in db Hfslq) tramite json a un webservice php.
ho provato con il percoso
sTipoRic is string
sTest is string =QRY_Photos.Path
sFoto is string = CompleteDir(fCurrentDir()) + sTest
vRequest is Variant
sTipoRic = "Add"

vRequest.Tipo_Ric = sTipoRic
vRequest.Descrizio = "test123"
vRequest.Image = Encrypt(fLoadBuffer(sFoto),"",cryptNone,encodeBASE64NoCR)

cMyRequest is httpRequest
cMyRequest.URL = "http://1xxxxx" // SERVER PRODUZIONE
cMyRequest.ContentType = "application/json"
cMyRequest.Content = VariantToJSON(vRequest)
cMyRequest.Method = httpPost
cMyResponse is httpResponse = HTTPSend(cMyRequest)

e con l'immagine presente nel db

bufFotobuf is Buffer =QRY_Photos.Photo
sFoto is string = Encode(fLoadBuffer(bufFotobuf), encodeBASE64)

ma nulla.
marcov
Site Admin
Messaggi: 18
Iscritto il: mar nov 16, 2021 12:24 pm

Re: Inviare Foto da Android a Webservice php [risolto]

Messaggio da marcov »

Ciao a tutti,

dopo giorni di mal di testa ho scoperto la problematica, davvero banale, prima di scrivere la query per l'inert aggiungere addslashes() per consentire l'inserimento dei caratteri speciali.
php:
$fileName = addslashes($immagine);

windevmobile:
sFotostr is string =fCurrentDir()+"/photos/"+QRY_Photos.Path
sFotosend is string =Encode(fLoadBuffer(sFotostr),encodeBASE64NoCR)

sDercrizio is ANSI string = "test "
sTipoRic = "Add"

vRequest is Variant
vRequest.Tipo_Ric = sTipoRic
vRequest.Descrizio = Encode(sDercrizio,encodeBASE64NoCR) //Encrypt(fLoadBuffer("testcrypt"),"",cryptNone,encodeBASE64)
vRequest.Image = sFotosend

cMyRequest is httpRequest
cMyRequest.URL = "https://xxxxx" // SERVER PRODUZIONE
cMyRequest.ContentType = "application/json"
cMyRequest.Content = VariantToJSON(vRequest)
cMyRequest.Method = httpPost
cMyResponse is httpResponse = HTTPSend(cMyRequest)
Rispondi