Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@superhawk610/file-select

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@superhawk610/file-select

Minimalist file/folder selection interface that includes Node/Express integration or works standalone.

  • 0.1.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
9
increased by800%
Maintainers
1
Weekly downloads
 
Created
Source

File Select

Minimalist file/folder selection interface that includes Node/Express integration or works standalone.

screenshot

Installation

npm install @superhawk610/file-select

Once you have installed the module via NPM, make sure to include the scripts and styles. You can either manually copy them from the /dist folder, or have them served for you if you are using Express via the included middleware (see Usage).

Requires jQuery 3.x or higher

Usage

Include the .js and .css files for the plugin. If you are manually copying them, link to wherever they are being served. If you are using Express, link to select.min.css and select.min.js as though they were at the root directory and they will be served by the included middleware.

<link rel="stylesheet" href="select.min.css">
...
<script type="text/javascript" src="select.min.js">

Simply call .fileSelect() on any div on your page to have it converted to a file select popup. Call it with the argument 'show' or 'hide' to have it displayed or hidden.

$('#myFileSelect').fileSelect()
$('#myFileSelect').fileSelect('show')

To get the user's selection from the interface, bind to the sfs.submit event fired by the element you called fileSelect() on. This event will return an Object array, each containing the name, type, and full path of each file selected. Here's an example:

$('#myFileSelect').on('sfs.submit', function(event, files) {
    console.log(files[0].name) // 'words.txt'
    console.log(files[0].type) // 'dir' or 'file'
    console.log(files[0].path) // '/home/user/words.txt'
})

The file select will need a data source. Currently, only the included Express middleware is available, but a future update will add the ability for custom data sources. In your Express app, include the following lines:

var fileSelect = require('@superhawk610/file-select')
app.use(fileSelect())

You will likely want to include this before any calls to express.static just so the middleware has precedence when serving its styles and scripts.

By default, your home directory is used as the starting directory when the modal is shown. If you would like to start at a different directory, specify it when activating the middleware, like so:

app.use(fileSelect({
    path: '/var/www'
}))

Be aware that this interface will expose your server's full file listing to any page on which it is visible. Use at your own risk.

Keywords

FAQs

Package last updated on 04 Aug 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc