Skip to content

Instantly share code, notes, and snippets.

@rafarubert
Created September 27, 2013 16:44
Show Gist options
  • Save rafarubert/6731451 to your computer and use it in GitHub Desktop.
Save rafarubert/6731451 to your computer and use it in GitHub Desktop.
$app->post('/estabelecimento/categoria/:id/update', function ( $id ) use ( $app ) {
$params = $app->request->params();
$header = array('Content-Type: multipart/form-data');
$token = key( $_SESSION['current_user'] );
$current_user = json_decode( $_SESSION['current_user'][$token] );
if ( isset( $_FILES ) and isset( $_FILES['imagem'] ) ):
$params['imagem'] = '@'.$_FILES['imagem']['tmp_name'];
endif;
$url = "http://api.phonemenu.com.br/categoria-produto/".$id."?session-token=".$token;
$ch = curl_init();
//curl_setopt($ch, CURLOPT_URL, $url);
//curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
//curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT");
//curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
//curl_setopt($ch, CURLOPT_POST, 1);
//curl_setopt($ch, CURLOPT_POSTFIELDS, $params );
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT");
curl_setopt($ch, CURLOPT_POSTFIELDS,http_build_query($params));
//curl_setopt($ch,CURLOPT_URL, $url);
//curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
//curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT");
//curl_setopt($ch, CURLOPT_RETURNTRANSFER, true );
//curl_setopt($ch, CURLOPT_POSTFIELDS,http_build_query($params );
$result = curl_exec($ch);
curl_close($ch);
$app->flash('success', 'Registro atualizado');
$app->redirect('/estabelecimento/categorias');
})->name('get-estabelecimento-categoria-update');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment