Here are the various jQuery plugins I have created

File Select


DOWNLOAD - 2.6kb

Example





Description


The file select plugin searches a directory for files and list them for other uses.

Options


Option NameDefaultWhat 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
filesnew Array()An array of the files listed - Used in plugin, DO NOT CHANGE
listImagesfalseSet 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.
NameDescription
filenameThe name of the file with the extension
filepathThe full path of the file with the extensions
fileextThe extension of the file, without the '.'
filesizeThe size of the file in bytes
lastmodThe 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+'" />'); 
});