File select

File select

In HTML, a file-select control is a component of a web form with which a user can select a file from his local machine. When the form is submitted (perhaps together with other form data), the file is uploaded to the web server. There, when the file arrives, some action usually takes place, such as saving the file on the web server. However, the particular action that takes place is determined by the server-side script to which the form is submitted.

Code example

Here is a code example of a web form with a file-select control. It is the input element with type="file" that creates the file-select control.

Rendering

When it comes to the rendering on the screen of a file-select control, there is some variation among web browsers. Typically, on a windows-based platform, user agents will render a file-select control as a text field, together with a "Browse" button. When the "Browse" button is pressed, a file dialog opens, with which actual file selection on one's platform can take place. After selection, the filename of the selected file is displayed in the text field, with its full path. Alternatively, instead of using the "Browse" button, the filename can be entered directly in the text field.

Functionality

The mechanism for form-based file upload was originally proposed in RFC 1867 (published November 1995), as an extension to HTML 2.0 (RFC 1866), after its publication. Form-based file upload then was incorporated in HTML 3.2, which explicitly refers to RFC 1867 for further information on form-based file upload.

HTML 4.01 does not, in itself, describe how the file-select control is supposed to work, but it does list RFC 2388 and RFC 1867 as references. [ [http://www.w3.org/TR/html401/references.html#ref-RFC2388 HTML 4 Specification References ] ]

Multiple file selection

The intention in RFC 1867 is that a single file-select control should allow selection of multiple files. This intention seems reflected in HTML 4.01, which, for the file-select control- type, states [ [http://www.w3.org/TR/html401/interact/forms.html#file-select Forms in HTML documents ] ]

This control type allows the user to select files so that their contents may be submitted with a form. The INPUT element is used to create a file select control.
It has been noted [http://www.cs.tut.fi/~jkorpela/forms/file.html File input (or "upload") in HTML forms ] ] that the plural "files" in the above quote is an indication that, in HTML 4.01, a single-file select-control still was supposed to handle selection of multiple files and not just a single file.

Accept attribute

RFC 1867 also introduced the accept attribute for the input element. This would enable file-type filtering based on MIME type for the file-select control.

In addition, it is proposed that the INPUT tag have an ACCEPT attribute, which is a list of comma-separated media types.
If an ACCEPT attribute is present, the browser might constrain the file patterns prompted for to match those with the correspondingappropriate file extensions for the platform.
Thus, a user-agent may restrict file selection, as, for example, in the following, restricted to GIF and PNG
On a Windows platform, this might mean that the user agent would show files only of the types specified in the browse-file dialog.

Browser Limitations

Basic support for the file-select control was adopted quickly by browser vendors. For example, already Internet Explorer 4 [ [http://msdn2.microsoft.com/en-us/library/ms535263.aspx input type=file Object ] ] , Netscape Navigator 2.0 and Opera 3.5 [http://www.blooberry.com/indexdot/history/opera.htm Browser History: Opera] ] recognized the input element of type="file" as a file-select control.

However, most modern browsers still do not implement the file-select control as it was intended, or lack certain features.

Cannot select multiple files

Generally, support is lacking for form-based upload of multiple files with a single file-select control. One source states that Opera supports multiple-file selection through a single file-select control. This was true for Opera versions starting from 3.5, in which the file-upload feature was introduced. However, with the first beta release of Opera 7 line, this function was no longer available.

JavaScript alternative

One solution is to use client-side scripting such as JavaScript for generating an extra file-select control for each file the user selects for upload. Using CSS, these extra file-select controls may be set not to display. An example of this technique is demonstrated in the [http://www.fyneworks.com/jquery/multiple-file-upload/ Multiple File Upload plugin] for jQuery. In this manner, the multiple-file upload problem is solved by providing as many file-select controls as the user has files to upload.

Accept attribute has no effect

Most, if not all, browsers make no use of the accept attribute.

Alternative Technologies

The lack of support for multiple-file selection has led developers to search for alternative solutions. These solutions have in common that they do not use the input type="file" element.

One solution is to use a Java Applet. An example of this is [http://sourceforge.net/projects/jupload/ JUpload] . It allows selection of multiple files within its file browser as well as offering a file-type filter.

An example of a Flash-based file-upload utility is [http://digitarald.de/playground/uplooad.html FancyUpload] , which is based on MooTools. It too allows selection of multiple files as well as offering a file-type filter.

References

External links

* [http://www.w3.org/TR/html4/interact/forms.html#file-select Specification of the file select control from W3C]


Wikimedia Foundation. 2010.

Игры ⚽ Нужно решить контрольную?

Look at other dictionaries:

  • File Replication Service — is a Microsoft Windows Server service for distributing shared files and Group Policy Objects. It replaced the (Windows NT) Lan Manager Replication service [1], and has been partially replaced by Distributed File System Replication. It is also… …   Wikipedia

  • Select (Unix) — select is a system call for polling multiple file descriptors. In C programming, it is declared in the header file sys/select.h or unistd.h. Those files and sys/time.h must be included to use select.int select(int nfds, fd set* readfds, fd set*… …   Wikipedia

  • SELECT — оператор языка Он используется для выборки нуля или более строк из одной или нескольких таблиц, хранимых процедур, представлений БД. В большинстве приложений SELECT является наиболее часто используемым оператором SELECT пользователь описывает… …   Википедия

  • Select — оператор языка Он используется для выборки нуля или более строк из одной или нескольких таблиц, хранимых процедур, представлений БД. В большинстве приложений SELECT является наиболее часто используемым оператором SELECT пользователь описывает… …   Википедия

  • Select Portfolio Servicing, Inc. — Select Portfolio Servicing, Inc. (SPS) is a loan servicing company founded in 1989 as Fairbanks Capital Corp. with operations in Salt Lake City, Utah and Jacksonville, Florida.Select Portfolio Servicing was created as a Utah company in 1989.… …   Wikipedia

  • Select — may refer to: * Select (SQL), a keyword in SQL * , an HTML element * Select (magazine), a British music magazine * MTV Select , a television program * Cable select, a setting on ATA devices that allows position on the cable to determine the role… …   Wikipedia

  • File system — For library and office filing systems, see Library classification. Further information: Filing cabinet A file system (or filesystem) is a means to organize data expected to be retained after a program terminates by providing procedures to store,… …   Wikipedia

  • select — ▪ I. select select 2 adjective used, visited, or bought only by a small group of people; = EXCLUSIVE: • Haute couture designers create superexpensive clothes that are sold to a select few customers worldwide. • This flat is situated on a small… …   Financial and business terms

  • File manager — For the Windows 3.x file manager, see File Manager (Windows). A file manager or file browser is a computer program that provides a user interface to work with file systems. The most common operations performed on files or groups of files are:… …   Wikipedia

  • File format — A file format is a particular way that information is encoded for storage in a computer file. Since a disk drive, or indeed any computer storage, can store only bits, the computer must have some way of converting information to 0s and 1s and vice …   Wikipedia

Share the article and excerpts

Direct link
Do a right-click on the link above
and select “Copy Link”