How to send a image file to server using in post function using swift 4

99 Views Asked by At

I want to send a image file to server using swift 4. what i have done is`

var editProfile_image_path = NSTemporaryDirectory() + "temp.jpg"

    Just.post(
    "http://justiceleauge.org/member/register",data: ["username": "abc", "password":"test"],files: ["product_image" : .url(URL(fileURLWithPath: editProfile_image_path), nil)]) { r in
    if r.ok {  } }
    do {
                    try UIImageJPEGRepresentation(self.profileImgvw.image!, 0.8)!.write(to: URL(fileURLWithPath:self.editProfile_image_path), options: .atomicWrite)
                } catch let error as NSError {
                   print(error)
                }

Help is much appreciated, what i want is to sent image file to the server. please help me.

0

There are 0 best solutions below