1

I'm using the jQuery FileTree plugin. The php connector uses scandir to get a folder's contents. After I upload images, my uploader script creates a "thumbs" folder, and then makes a thumbnail version of the image, and stores it there.

Users will be operating on the files within each image folder, but I don't really want them seeing the "thumbs" folder that's within each image folder. I could move the thumbs folder to some other place, but that would be kind of a huge undertaking.

Is there a way to make the "thumbs" folder my upload script creates a hidden folder, unseeable by scandir?

$files  = scandir($postDir);
$returnDir  = substr($postDir, strlen($root));

enter image description here

TARKUS
  • 2,170
  • 5
  • 34
  • 52
  • 1
    In php you can use is_dir to check each thing found by scandir, and remove it from the array. Not sure if this is useful in jquery though. – Josiah Apr 09 '16 at 18:53
  • The actual code that will be doing the filtering is a php script. It is the "connector" that works to provide the jquery with the files list. – TARKUS Apr 10 '16 at 01:35
  • 1
    It looks to me like with that connector you can just send a hidden field "onlyFiles" with a value of true to accomplish what you want. Or comment out line 57. – Josiah Apr 10 '16 at 01:46
  • See Matt Gibson's answer below. It is the solution to my problem. – TARKUS Apr 10 '16 at 14:27

1 Answers1

1

Make a custom version of jQueryFileTree's php connector, adding your exclusion to the filtering, around line 55:

if( file_exists($postDir . $file) && $file != '.' && $file != '..' && $file != 'thumbs') {

Then use that script instead of the standard connector by passing its name as the script parameter to the fileTree function when creating the tree on the JS side.

(Depending on what states your directories can be in, e.g. whether you'll always have a "thumb" folder, etc., you may also need to adjust the if( count($files) > 2 ), but this should give you the basic principle -- just create your own connector and customise it as necessary.)

Matt Gibson
  • 37,886
  • 9
  • 99
  • 128