I'm trying to upload some images with a PHP script. In my HTML page I've made a <form>
to load the files this way :
<form action="{{ path("uploader_photos") }}" method="post" enctype="multipart/form-data">
<input type="file" id="file" name="files" style="display: none" multiple/>
<button type="submit" form="pic_add" >Download</button>
And this is the controller method where i should get the $_POST
elements :
public function uploaderAction(){
$mail = $_SESSION['mail'];
$pass = $_SESSION['password'];
$oauth = new OAuth($mail, $pass);
$baseUrl = "http://api.localhost/v1/";
$url = "{$baseUrl}upload/" . $mail . '/photosup';
$oauth->fetch($url, $_REQUEST, OAUTH_HTTP_METHOD_POST);
$reponseInformations = json_decode($oauth->getLastResponse(), true);
if (!$_POST) {
return new Response(json_encode(array('erreur' => $reponseInformations['erreur'])), 500, array('Content-Type' => 'application/json'));
}
//return $this->redirect('photos');
}
The issue that i'm always gettin an empty $_POST
variable, i'm making sure to passe the parameters in the post request like in the image :
So any one to help please !
$_FILES
var_dump :
array (size=1)
'files' =>
array (size=5)
'name' => string 'Falling iron man.jpg' (length=20)
'type' => string 'image/jpeg' (length=10)
'tmp_name' => string '/tmp/phpn5wWfK' (length=14)
'error' => int 0
'size' => int 507102