I try to use the BlueImp jQuery File Uploader ( https://github.com/blueimp/jQuery-File-Upload/wiki/Basic-plugin ). It works well, but only with the orinial name attribute of the input field, "files[]". When I use an other name, the JSON response is empty :
{"files":[]}
This is my code :
<tr>
<td>
<label>Photos</label>
</td><td id="photos_container">
<div class="progress">
<div class="bar" style="width: 0%;"></div>
</div>
<span class="btn btn-success fileinput-button">
<i class="glyphicon glyphicon-plus"></i>
<span>Select files...</span>
<input id="photos" type="file" name="photos[]" multiple>
</span>
</td>
</tr>
<script>
jQuery(document).ready(function($){
$(function () {
$('#photos_container').fileupload({
url: 'tmp/',
dataType: 'json',
fileInput: $('#photos'),
paramName: 'photos[]',
progressall: function (e, data) {
var progress = parseInt(data.loaded / data.total * 100, 10);
$('#photos_container .progress .bar').css(
'width',
progress + '%'
);
},
done: function (e, data) {
$.each(data.result.files, function (index, file) {
$('<p/>').text(file.name).appendTo('#photos_container');
});
}
});
});
});
</script>
I repeat, but the code works great with the default name of input button "files[]", so the problem isn't a path problem.
EDIT: And I try with and without the fileInput and the paramName options, but I didn't work
The name
attribute is used to reference elements in a JavaScript, or to reference form data after a form is submitted.
Your file data will be there in photos
property.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.