I want to add filenames that are uploaded to an array in a hidden input field in form. This is what I have in my form:
<input type="hidden" name="myFiles[]" id="myFiles" value="">
This is my fileupload:
$('#fileupload').fileupload({
dataType: 'json',
add: function (e, data) {
$("#submitentity").on('click', function () {
data.submit();
});
},
done: function (e, data) {
var filename = data.files[0]['name'];
var type = data.files[0]['type'];
var row = [];
row["name"] = filename;
row["type"] = type;
myList[i] = row;
i++;
e.preventDefault();
},
stop: function(e){
$("#myFiles").val(myList);
console.log(myList);
submitForm();
}
});
function submitForm(){
$('#form-Entity')[0].submit();
}
As you can see I have console.log(myList) what shows:
[Array[0], Array[0]]
0: Array[0]
length: 0
name: "Hollowbody 4.gif"
type: "image/gif"
1: Array[0]
length: 0
name: "Hollowbody 5.gif"
type: "image/gif"
Then I submit the form. But in my backend I get
array (size=1)
0 => string '' (length=0)
When I want to check the myFiles...
What am I doing wrong?
UPDATE:
if ($request->getMethod() == 'POST')
{
$form->bind($request);
$data = $form->getData();
if($form->isValid())
{
$data = $form->getData();
var_dump($request->request->get('myFiles'));
die();