How to I preload existing files and display them in the blueimp upload table?

后端 未结 4 812
轮回少年
轮回少年 2020-12-15 09:33

I am using the jquery-ui version of Blueimp upload and I like how I can format a table and display files that were just uploaded. But I\'d like to use it as a file manager a

4条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-15 10:10

    I also had the same problem. It is not magic how it works. I recommend to examine the UploadHandler.php file. Then you will be able to modify this plugin accordind to your needs.

    The code above in your second post is just an ajax call to the uploader script (by default index.php in server/php/ folder). The call method is set to "get" by default in $.ajax object.

    Open the UploadHandler.php file and go to the class method "initialize(...)". You will see how the call with "get" handled. UploadHandler calls the class method this->get(.:.) to prepare and send the list of existing files. If you use other upload directory, you need pass a parameter to the UploadHänder. Simply chage the url property in the $.ajax object like :

    url: $('#fileupload').fileupload('option', 'url')+'?otherDir='+myDir,
    

    then you should initialize the option property of the UploadHandler before you create a new UploadHandler object like this:

    $otherDir = trim($_REQUEST['otherDir']);
    $otherDir_url = [anyURL] .'/'.$otherDir;//so that the files can be downloaded by clicking on the link
    
    $options = array(
    'upload_dir'=> $otherDir,
    'upload_url'=> $otherDir_url,
    );
    
    $upload_handler = new UploadHandler($options);
    

提交回复
热议问题