I’ve been working on a web app using httpsocket. I need to upload the contents of a file to a server. I have an example of the uploading code in PHP, but I’m not sure how to convert it to Xojo. The PHP code is:
I understand most of the above code, but I don’t know how to handle the array that is being created in the 3rd line and then sent to the server in the 7th and 8th lines. Can anybody advise how to turn this into the appropriate SetRequestHeader and/or SetRequestContent statements?
[quote=227780:@Kevin Clark]I’ve been working on a web app using httpsocket. I need to upload the contents of a file to a server. I have an example of the uploading code in PHP, but I’m not sure how to convert it to Xojo. The PHP code is:
I understand most of the above code, but I don’t know how to handle the array that is being created in the 3rd line and then sent to the server in the 7th and 8th lines. Can anybody advise how to turn this into the appropriate SetRequestHeader and/or SetRequestContent statements?[/quote]
Ch isn’t an array. It’s an object, like the object you’d get from
dim h as new HTTPSovket
Then lines 4-6 set the url, method and request content. Line 7 is the equivalent of SendRequest.
// Synchronous post
dim result as String = HTTPSecureSocket1.Post(target_url, 30)[/code]
[/quote]
There’s only one problem with your solution… the original code sends the contents of the file. This code simply sends the filename with an @ symbol in front of it.
You’d need to use a binarystream to read the file’s data and put THAT into the file_contents entry.