|
upload an image with HTTPRequest |
Started by Richard HO, Aug., 19 2015 8:10 AM - 8 replies |
| |
| | | |
|
| |
Registered member 7 messages Popularité : +1 (1 vote) |
|
Posted on August, 19 2015 - 8:10 AM |
Hi,
If I get a photo from IOS camera, and store it in a variable named IMG_profile, and I would like to upload it to a http server which is running PHP, how can I do it with HTTPRequest?
Or there is other methods?
Thank you in advance
Richard |
| |
| |
| | | |
|
| | |
| |
Posted on August, 19 2015 - 11:41 AM |
In android I use a webservice. I encode the image with base64 and serverside I decode the string and save the image. |
| |
| |
| | | |
|
| | |
| |
Posted on August, 19 2015 - 1:02 PM |
Hi Richard,
you need to have a php page able to receive your image (I don't do php, so that one is on you) - you need to convert the image into a string to send it (base64 encoding, by example, or simply buffertohexa) on the IOS side - you need to decode it on the php side.
depending on the side of the image, you may also have to do all that in POST mode instead of get (get is limited in the parameters size)
There is an example of all that in WXReplication, but not with a php page, with an awp one
Best regards
-- Fabrice Harari International WinDev, WebDev and WinDev mobile Consulting
Already there: WXShowroom.com, WXReplication (open source) Coming soon: WXEDM (open source) More information on http://www.fabriceharari.com
On 8/19/2015 12:10 AM, Richard HO wrote:
Hi,
If I get a photo from IOS camera, and store it in a variable named IMG_profile, and I would like to upload it to a http server which is running PHP, how can I do it with HTTPRequest?
Or there is other methods?
Thank you in advance
Richard |
| |
| |
| | | |
|
| | |
| |
Registered member 7 messages Popularité : +1 (1 vote) |
|
Posted on August, 20 2015 - 6:40 AM |
Hi, KJVA and Fabrice,
Thank you so much for your replies, I have successfully encoded the image in Base64, but I found HTTPRequest post method is not supported in WinDev Mobile, so I couldn't get the post parameters at my server side. I have also tried HTTPSendForm function, and got the same result.
P.S. I set the Content-type to "multipart/form-data", I did this successfully by using POSTMAN(a Restful client).
@KJVA what function do you use? GET in HTTPRequest or HTTPSendForm?
KJVA wrote:
In android I use a webservice. I encode the image with base64 and serverside I decode the string and save the image. Fabrice Harari wrote: Hi Richard, you need to have a php page able to receive your image (I don't do php, so that one is on you) - you need to convert the image into a string to send it (base64 encoding, by example, or simply buffertohexa) on the IOS side - you need to decode it on the php side. depending on the side of the image, you may also have to do all that in POST mode instead of get (get is limited in the parameters size) There is an example of all that in WXReplication, but not with a php page, with an awp one Best regards -- Fabrice Harari International WinDev, WebDev and WinDev mobile Consulting Already there: WXShowroom.com, WXReplication (open source) Coming soon: WXEDM (open source) More information on http://www.fabriceharari.comOn 8/19/2015 12:10 AM, Richard HO wrote: Hi, If I get a photo from IOS camera, and store it in a variable named IMG_profile, and I would like to upload it to a http server which is running PHP, how can I do it with HTTPRequest? Or there is other methods? Thank you in advance Richard |
| |
| |
| | | |
|
| | |
| |
Posted on August, 20 2015 - 9:07 AM |
I use the webservice functionality in WindevMobile. I implemented a webservice in netbeans and deployed that to a tomcat server. I added the wsdl to my windevmobile project.
aImage is wsKAMapp.sendImage aImageResult is wsKAMapp.sendImageResponse aImage.bestand = Crypt(Bestand.foto,"",cryptNone) aImage.bestandID = nBestandID_ws
aImageResult = wsKAMapp.sendImage(aImage)
wsKAMapp is the name of my webservice sendImage is a method of my webservice, it expects a base64 encoded string and an ID integer Bestand.foto is my image
for use of a webservice you can check the windev helpdocuments |
| |
| |
| | | |
|
| | |
| |
Registered member 7 messages Popularité : +1 (1 vote) |
|
Posted on August, 24 2015 - 1:54 AM |
Thank you, KJVA,
I will try and let you know if it works for me |
| |
| |
| | | |
|
| | |
| |
Registered member 7 messages Popularité : +1 (1 vote) |
|
Posted on August, 24 2015 - 5:50 AM |
Hi, KJVA,
I did some research the help documents on web service, but it seems it doesn't work in my case. The service I have done is using JSON instead of SOAP(XML?). So is your web service SOAP?Meanwhile, I have looked into the docs for JSON service support, I couldn't find it. WinDev Mobile doesn't well support json, I suppose. |
| |
| |
| | | |
|
| | |
| |
Posted on August, 24 2015 - 8:43 AM |
Richard HO wrote:
Hi, KJVA,
I did some research the help documents on web service, but it seems it doesn't work in my case. The service I have done is using JSON instead of SOAP(XML?). So is your web service SOAP?Meanwhile, I have looked into the docs for JSON service support, I couldn't find it. WinDev Mobile doesn't well support json, I suppose.
indeed I use SOAP.
I don't know how to use json in Windev |
| |
| |
| | | |
|
| | |
| |
Registered member 7 messages Popularité : +1 (1 vote) |
|
Posted on August, 26 2015 - 6:02 AM |
I finally found a solution. For those who too looks for it, I post it here. Instead of using HTTPRequst(), I use HTTPSendForm(). If you cannot receive the post variables on the server side, please convert it to ANSI by using UnicodeToAnsi()
Example code:
HTTPCreateForm("FORM") HTTPAddParameter("FORM", "name", UnicodeToAnsi("John")) HTTPAddFile("FORM", "photo", IMG_Photo)
IF HTTPSendForm("FORM", sRequestUrl) THEN bufResponse is Buffer = HTTPGetResult() jz is Variant =JSONToVariant(bufResponse)
ELSE Error(ErrorInfo()) END
On the server side you, PHP can get the file in $_FILE
Hope this help.
Regards, Richard |
| |
| |
| | | |
|
| | | | |
| | |
|