0
$('#lang_choice1').each(function() {
var lang = $(this).val();
$('#lang_files').empty();
$.ajax({
type: "POST",
url: '<?= site_url('translation/language/getDirContents') ?>',
data: {"lang":lang},
dataType:"json",
success: function (data) {
$.each(data,function(id,dir) //here we're doing a foreach loop round each directory with id as the key and directory as the value
{
var opt = $('<option />'); // here we're creating a new select option with for each directory
opt.val(dir);
opt.text(dir.substr(dir.lastIndexOf("\\")+1));
$('#lang_files').append(opt); //here we will append these new select options to a dropdown with the id
});
$("#lang_files").val($("#lang_files option:first").val());
}
});
return false;
});
的opt.text(dir.substr(dir.lastIndexOf("\\")+1));
的用法在UNIX system.But在窗戶導致問題的正常工作。在UNIX中,它需要是「/」我如何使它兼容在Windows和基於Unix的系統中使用?問題「//」在UNIX
參見[RecursiveDirectoryIterator(https://secure.php.net/manual/en/class.recursivedirectoryiterator.php)。 –
幾乎是https://stackoverflow.com/questions/14304935/php-listing-all-directories-and-sub-directories-recursively-in-drop-down-menu的副本。那裏的答案應該只需稍作修改即可獲得文件而不是目錄。 –