doushu5451 2015-07-28 19:33
浏览 47
已采纳

获取AS3文件夹中的文件数

I made a flash webpage with a file-upload system for uploading pdf's to a subfolder in the same folder where the swf is hosted. I want to make a very simple system to count the number of files in that folder from inside the AS3 of the main webpage (with the purpose of displaying it somewhere in the flash page..). I still haven't found a straight answer on how to do it (or if it's even possible). I think that maybe i have to use an additional php script to count the files..

Any idea is welcome! Thx in advance!

  • 写回答

1条回答 默认 最新

  • dongrouli2667 2015-07-30 13:58
    关注

    You will need a server-side script. For example, using PHP you can use scandir() to read the files and json_encode() to output it as JSON. For example:

    // scandir.php
    echo json_encode(scandir("path/to/dir"));
    

    Then you simply load the JSON from AS3 using URLLoader. For example:

    var urlLoader:URLLoader = new URLLoader(new URLRequest("http://path/to/scandir.php"));
    urlLoader.addEventListener(Event.COMPLETE, complete);
    function complete(e:Event):void {
            var files:Array = JSON.parse(urlLoader.data);
            trace(files.length);
    });
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 使用yolov5-7.0目标检测报错
  • ¥15 对于这个问题的解释说明
  • ¥200 询问:python实现大地主题正反算的程序设计,有偿
  • ¥15 smptlib使用465端口发送邮件失败
  • ¥200 总是报错,能帮助用python实现程序实现高斯正反算吗?有偿
  • ¥15 对于squad数据集的基于bert模型的微调
  • ¥15 为什么我运行这个网络会出现以下报错?CRNN神经网络
  • ¥20 steam下载游戏占用内存
  • ¥15 CST保存项目时失败
  • ¥20 java在应用程序里获取不到扬声器设备