trafalgarlow trafalgarlow - 7 months ago 35
Objective-C Question

Upload image from Library Photos iOS to cakephp

I'm trying to upload an UIImage that I took from the library photos on iOS to cakephp. The problem I'm really a beginner on cake so I have no idea how it works. I added the plugin: cakemanager/cakephp-utils to cake then added an upload behavior then in my table I initialized my attribute just like this

$this->addBehavior('Utils.Uploadable', [
'control_mfront' => [
'fields' => [
'filePath' => 'control_mfront',
'field' => 'id',
'path' => '{ROOT}{DS}{WEBROOT}{DS}img{DS}{model}{DS}{field}{DS}',
'fileName' => 'control_mfront'.date('YmdHis').'.{extension}','removeFileOnUpdate' => false

and on my Controller on the post I wrote this :

$this->request->data['model_mfront']['name'] = 'model_mfront';

until now on the website it works fine but for iOS i didn't understand how should I post the image . is it on NSData format !?
and what next ?!



You can convert your imagedata(NSData) in base64 string and then send it to server as post request.