File Select
DOWNLOAD - 2.6kb
Example
Description
The file select plugin searches a directory for files and list them for other uses.
Options
| Option Name | Default | What it does |
|---|---|---|
| dir | '/' (current directory) | The directory to search for files |
| exts | '*' (all files) | The file extensions to find |
| phpFile | 'get_files.php' | The PHP file that gets all the files for the plugin |
| defaultText | 'SELECT' | The text that is inside the button |
| buttonClass | 'file_selector' | The class of the button |
| listClass | 'file_list' | The class of the list |
| fileClass | 'file' | The class of the files in the list |
| files | new Array() | An array of the files listed - Used in plugin, DO NOT CHANGE |
| listImages | false | Set this to true if you want images to be shown in the list instead of filenames |
Callback
The callback function has one argument. This argument holds the selected file's information.
| Name | Description |
|---|---|
| filename | The name of the file with the extension |
| filepath | The full path of the file with the extensions |
| fileext | The extension of the file, without the '.' |
| filesize | The size of the file in bytes |
| lastmod | The last modification time of the file |
How to use
$('#spanID').fileSelect(options, callback);
Get all the jpg and png files in the 'images' folder. When an image is selected, show the image on the button.
$('#spanID').fileSelect({
exts : 'jpg|png',
dir : 'images',
listImages : true
},function(file){
$(this).html('<img src="images/'+file.filename+'" />');
});