You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I want to upload an image to server. How can I set image to url?
function HTTPMultipartBeginMethod(url, fileData, completionHandler)
puts ('HTTPMultipartBeginMethod')
print ('request url: '..url)
local requestcallback = function(body, response)
if response == nil then
HTTPFailureProcessing(0, nil, completionHandler)
else
local statusCode = response:statusCode()
if statusCode == 200 then
print 'request successed'
HTTPSuccessProcessing(statusCode, body, completionHandler)
else
print 'request failure'
HTTPFailureProcessing(statusCode, body, completionHandler)
end
end
end
local base64 = require 'Base64'
local avatar = base64.enc(fileData)
local requestheaders = {}
requestheaders['Content-Type'] = 'multipart/form-data; boundary=0xKhTmLbOuNdArY'
local requestbody = [[
--0xKhTmLbOuNdArY
Content-Disposition: form-data; name="submit-name"
Larry
--0xKhTmLbOuNdArY
Content-Disposition: form-data; name="avatar"; filename="image.png"
Content-Type: application/octet-stream
... contents of image.png ...
hello
--0xKhTmLbOuNdArY--]]
puts (requestbody)
wax.http.request{ url, headers = requestheaders, body = requestbody, callback = requestcallback}
end
The text was updated successfully, but these errors were encountered:
I want to upload an image to server. How can I set image to url?
function HTTPMultipartBeginMethod(url, fileData, completionHandler)
puts ('HTTPMultipartBeginMethod')
print ('request url: '..url)
local requestcallback = function(body, response)
if response == nil then
HTTPFailureProcessing(0, nil, completionHandler)
else
local statusCode = response:statusCode()
if statusCode == 200 then
print 'request successed'
HTTPSuccessProcessing(statusCode, body, completionHandler)
else
print 'request failure'
HTTPFailureProcessing(statusCode, body, completionHandler)
end
end
end
local base64 = require 'Base64'
local avatar = base64.enc(fileData)
end
The text was updated successfully, but these errors were encountered: