使用PHP正确使用fine-uploader初始文件列表/ getInitialFiles()

I have successfully set up an environment where files get uploaded to a specified PHP folder and can also be deleted by the user, so the basic set up mainly using the provided example php server code works.

However, the getInitialFiles() method is not really implemented in the example, and I'm struggling to get it working.

This is what is defined in handler.php:

public function getInitialFiles() {
    $initialFiles = array();
    for ($i = 0; $i < 5000; $i++) {
        array_push($initialFiles, array("name" => "name" + $i, uuid => "uuid" + $i, thumbnailUrl => "/test/dev/handlers/vendor/fineuploader/php-traditional-server/fu.png"));
    }
    return $initialFiles;
}

So basically this function simply puts dummy files into the array and returns them - so far, this also works.

I am struggling with displaying all files within my defined upload-directory. Since the handler.php creates sub-folders named by the UUID of the uploaded item, I can't simply print all file names within the upload directory, but would need to access those directories and then scan the files. Easy enough, but in the end I am required to implement a certain logic for already existing files on the prod environment, hence I try to understand what exactly is going on. The tough part is, that there are several files already existing in a folder structure, which would need to be displayed by the FineUploader. Even if I get hold of the file, I wouldn't know how to correctly access a file, not knowing it's UUID.

Further, I wouldn't know how to correctly send parameters to the getInitialFiles endpoint - for example a starting directory or an file id prefix. All my tries to enhance this method horribly failed.

So here are my concrete questions:

  1. is it somehow possible to access existing files, which were not uploaded via FineUploader on my server?
  2. how can I correctly access those files, given the example that I want to display all files in the folder (f.e.) uploads/:id/ (which holds files 1.png, 2.png, calc.xls) .. where :id is a parameter sent while setting up the fineUploader instance on my .php site?

Thanks!

is it somehow possible to access existing files, which were not uploaded via FineUploader on my server?

I don't know. That's entirely dependent on your code/environment.

how can I correctly access those files

I don't know. That's entirely dependent on where/how you store them.

You shouldn't need to "access" these files. You just need to return information to Fine Uploader that describes them. You should have a database with this information.

As the documentation states, the JSON you return to Fine Uploader when asked for the initial file list...

must be a JSON array containing Objects for each file to be fed into the uploader.

In PHP, you'll return something like this, which represents only the required properties for a traditional endpoint environment:

json_encode(array(array("name" => "foo", "uuid" => "abc123"), array("name" => "bar", "uuid" => "abc124")))

Above, you are instructing Fine Uploader to represent two specific files in the initial list of files.