Iphone> Uploading UIImage object to server via ASI

2019-09-02 20:03发布

问题:

I got a UIImage object with no name. (but when I save UIImage to my photo library it gets a name like IMG_00000.jpg)

I just don't know how to use this name for request parameter. (or whatever name it is...)

That should be like,

`[request addData:imageData withFileName:@"%@.jpg", self.IDON'TGETIT]`

what can I use for name of this UIImage?

How can I make it? (property? is there protocol or something?)

回答1:

try:

NSData *imageData = UIImagePNGRepresentation(yourUIImage);
[request setData:imageData withFileName:@"myphoto.jpg" andContentType:@"image/jpeg" forKey:@"file"];