【问题标题】:how to use data-jfiler-files in jquery filer?如何在 jquery filer 中使用 data-jfiler-files?
【发布时间】:2017-07-28 23:47:00
【问题描述】:

我使用过 jquery 文件管理器,我尝试使用data-jfiler-files 属性在 jquery 文件管理器中编辑模式。

但我没有得到结果..我做错了什么?

PHP

<?php
    $dummyarr1 = array();
    foreach($templateVal_array['media_src'] as $Ind){
        $dummyarr = array();

        $dummyarr['name'] = $Ind['oname'];
        $dummyarr['size'] = (int)str_replace(',', '', $Ind['size']);
        $dummyarr['type'] = "image/jpg";
        $dummyarr['file'] = "http://localhost/datacapture/evt/media_src/".str_replace(' ', '_', $Ind['fname']).".".$Ind['ext'];

        $dummyarr1[] = $dummyarr;
    }
?>

<input type="file" name="media_src[]" class="filepicker-custom" data-jfiler-files = <?php echo json_encode($dummyarr1); ?> multiple="multiple" />

我也尝试了以下方法,效果很好

$(".filepicker-custom").filer({
    limit: 3,
    maxSize: 3,
    extensions: ["jpg", "jpeg", "png", "gif", "txt", "docx", "doc", "pdf"],
    showThumbs: true,
    addMore: true,
    files: [{
      name: "appended_file.jpg",
      size: 777835,
      type: "image/jpg",
      file: "http://localhost/datacapture/evt/media_src/Avg_rain_fall-58bfd786d435c.jpg",
    },{
      name: "appended_file_2.png",
      size: 620888,
      type: "image/png",
      file: "http://localhost/datacapture/evt/media_src/Avg_rain_fall-58bfd786d435d.jpg",
   }]
});

【问题讨论】:

    标签: php jquery jquery-filer


    【解决方案1】:

    试试这个data-jfiler-files='&lt;?php echo json_encode($dummyarr1);?&gt;'

    【讨论】:

    • 纯代码答案对教育 SO 读者的作用很小。请编辑您的答案以包含一些解释。您的答案在审核队列中,因为它已被标记为低质量。
    猜你喜欢
    • 2017-08-28
    • 2017-04-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-12-26
    • 1970-01-01
    相关资源
    最近更新 更多