support html5 multiple upload

closes 
This commit is contained in:
onli 2014-04-23 02:27:14 +02:00
parent a04a2de5c5
commit f704df9365
3 changed files with 85 additions and 62 deletions

@ -265,13 +265,22 @@ switch ($serendipity['GET']['adminAction']) {
serendipity_request_end();
}
} else {
if (!is_array($serendipity['POST']['target_filename'])) {
if (!is_array($_FILES['serendipity']['name']['userfile'])) {
break;
}
foreach($serendipity['POST']['target_filename'] AS $idx => $target_filename) {
$uploadfile = &$_FILES['serendipity']['name']['userfile'][$idx];
$uploadtmp = &$_FILES['serendipity']['tmp_name']['userfile'][$idx];
foreach($_FILES['serendipity']['name']['userfile'] AS $idx => $uploadfiles) {
if (! is_array($uploadfiles)) {
$uploadfiles = array($uploadfiles);
}
$uploadFileCounter=-1;
foreach($uploadfiles AS $uploadfile) {
$uploadFileCounter++;
$target_filename = $serendipity['POST']['target_filename'][$idx];
$uploadtmp = $_FILES['serendipity']['tmp_name']['userfile'][$idx];
if (is_array($uploadtmp)) {
$uploadtmp = $uploadtmp[$uploadFileCounter];
}
if (!empty($target_filename)) {
$tfile = $target_filename;
} elseif (!empty($uploadfile)) {
@ -335,6 +344,7 @@ switch ($serendipity['GET']['adminAction']) {
}
}
}
}
if (isset($_REQUEST['go_properties'])) {
echo serendipity_showPropertyForm($new_media);

@ -18,7 +18,7 @@
<div id="upload_form_1" class="upload_form">
<div class="form_field clearfix">
<label for="userfile_1" class="uploadform_userfile_label">{$CONST.ENTER_MEDIA_UPLOAD}</label>
<input id="userfile_1" class="uploadform_userfile check_input" name="serendipity[userfile][1]" type="file">
<input id="userfile_1" class="uploadform_userfile check_input" name="serendipity[userfile][1]" type="file" multiple>
</div>
<div class="form_field clearfix">

@ -1296,6 +1296,19 @@ $(function() {
});
}
if ($('.uploadform_userfile').length > 0) {
$('.uploadform_userfile').change(function() {
if ($(this).get(0).files.length > 1) {
$(this).parent().siblings(':first').fadeOut();
$(this).parent().siblings(':first').find('input').val('');
$(this).attr('name', $(this).attr('name') + '[]');
}
if ($(this).get(0).files.length == 1) {
$(this).parent().siblings(':first').fadeIn();
}
});
}
// reopen detail element after spamblock action
if ($('#serendipity_comments_list').length > 0 && window.location.hash && $('#' + window.location.hash.replace('#', '')).length > 0) {
$('#' + window.location.hash.replace('#', '')).find(".toggle_info").click();