On a computer: a thing that stores information or a thing that stores thing. IRL: generally a 15 inch by 11 inch manilla sheet of cardboard that contains papers or other documents.

On a chessboard, a vertical row of squares.

Best controled by rooks and queens.

See also: rank.

"file" is also a Unix command for determining the type of a file. Its output will almost always contain the word "text" for a text file which can safely be viewed with "more" or edited, and "data" or "executable" for a binary file.

file carries out three tests to determine a file's type. First it checks for empty files and for special files such as symbolic links. Then it consults the /etc/magic file, which has a list of "magic numbers" which appear near the beginning of binary files and the types of binary file they corespond to. Finally, if the file is an ASCII file, it attempts to guess its language by looking for keywords near the beginning of the file.

file does not always get the answer right - The Unix-Haters Handbook gives an example of the results obtained by typing "file *" in a fairly large directory. It seems to have particular difficulty in recognising Fortran, apparently because it only thinks a file is Fortran if it starts with a comment. Since my Fortran code tends to have "program name" before the comments, it is never recognised.

In HTML, file is one of the type attributes of the input element in a form. See under form for a good overview of forms; I just want to add some detail specific to the file type.

Visually, <input type=file> creates a text box with a browse button next to it, like the combination <input type=text><input type=button value="Browse">. The text part of it can be varied with the size and maxlength attributes. As with an ordinary text box, <input type=file size=20 maxlength=100> allows 20 characters to be visible, and 100 characters altogether to be entered, scrolling along the text box.

There doesn't seem to be any way of changing the literal text "Browse" (well, it says that on my browser though it's probably browser-dependent), nor the placement relationship between the text and button parts. This is a single component, and while the literal "Browse" would be the value of a button, it's not a distinct attrribute of a file input, the value of which is the text in the box, intended to be a file-name.

When you click the button, a system-dependent file-selection dialogue opens. This is out of the control of HTML. Once you open/okay/whatever a file, its name gets placed in the value of the text box. As fully specified file-names on a typical machine can get quite long, this overrides the length restriction imposed by maxlength. That only restricts what you can enter by typing.

There's not a lot your HTML page can do with a file: neither HTML nor JavaScript can read them; so usually what it does is have the form submit them to some other script, program, or volcano god, to wreak its will on. Now form submissions usually include name/value pairs: you give an input element a name attribute and it passes on whatever value the element had when you pressed Submit. In the case of a file, this is probably unwanted behaviour, since the value is just the file name. So you have to specify that what gets passed is the file contents, thus: <form enctype="multipart/form-data" method=post>

There is a sub-attribute accept which is said to restrict the kind of files the element will accept. Its value is a comma-separated list of MIME encodings; for example <input type=file accept="images/*">. I find my browser button actually accepts any kind even if this is set, but perhaps it won't post it if you have method=post -- I didn't check.

One good thing HTML and JavaScript together can do with files is manipulate images. This is really why I'm writing this node: one little gotcha is worth documenting. Here's the bones of how to change an image:

<form name=myform>
<img name=myimg src=mydefault.jpg>
<input type=file name=myfileinput onChange=ChangeImg()>
<script>
  function ChangeImg () {
    document.myimg.src =
      document.myform.myfileinput.value;
  }
</script>
</form>
If you just type the name into the text box, this will happily accept spaces and relative file-names, such as images/cute kittens.jpg. But it didn't work when I chose a file from the browser. Why not?

Relative file names are relative to some base it already knows about, such as http://www.example.com/ or some base directory. The images/cute kittens.jpg gets appended to that to form the full name, which therefore begins with a protocol such as http://. Now all the browser does is return a file name as its value. This probably begins with the top-level disk identifier, such as C:/ or Macintosh HD/. It doesn't begin with a protocol -- it looks like a relative file name, http://www.example.com/C:/... So you need to... or at least on my browser and system I needed to, since this could well be dependent... prefix the absolute file name with the protocol file:/// (with three slashes) to get the src property to recognize it:

<script>
  function ChangeImg () {
    document.myimg.src =
      'file:///' + document.myform.myfileinput.value;
  }
</script>

Another small gotcha is that if you read off the src property (e.g. by assigning its value to a text box or showing it in an alert), you'll find it's been escape()'d, the spaces having been turned into %20 and in my case the slashes having been reversed. This is automatic -- just because it comes out like that doesn't mean you have to feed it in with escape(). Though you can, it seems harmless -- but don't escape() the file:/// prefix! (Another thing I did wrong.)

...Oh damn. Except that now doesn't work for hand-entered relative names. * sigh * Well I'm sure there's a solution if I keep looking... Test for a colon in the name string and only add the protocol if there is one?

HTML pedants might like to use lots of redundant punctuation in their working code and not leave it off like me. Please /msg me with real (non-pedantry) errors etc.

File (?), n. [F. file row (cf. Pr., Sp., Pg., & It. fila), LL. fila, fr. L. filum a thread. Cf. Enfilade, Filament, Fillet.]

1.

An orderly succession; a line; a row; as: (a) (Mil)

A row of soldiers ranged one behind another; -- in contradistinction to rank, which designates a row of soldiers standing abreast; a number consisting the depth of a body of troops, which, in the ordinary modern formation, consists of two men, the battalion standing two deep, or in two ranks

.

The number of files in a company describes its width, as the number of ranks does its depth; thus, 100 men in "fours deep" would be spoken of as 25 files in 4 ranks.

Farrow.

(b)

An orderly collection of papers, arranged in sequence or classified for preservation and reference; as, files of letters or of newspapers; this mail brings English files to the 15th instant

. (c)

The line, wire, or other contrivance, by which papers are put and kept in order

.

It is upon a file with the duke's other letters. Shak.

(d)

A roll or list

. "A file of all the gentry."

Shak.

<-- (e) (computer) a collection of data on a recording medium treated as a unit for the purpose of recording or reading, accesible by use of a file name. -->

2.

Course of thought; thread of narration.

[Obs.]

Let me resume the file of my narration. Sir H. Wotton.

File firing, the act of firing by file, or each file independently of others. -- File leader, the soldier at the front of any file, who covers and leads those in rear of him. -- File marching, the marching of a line two deep, when faced to the right or left, so that the front and rear rank march side by side. Brande & C. --Indian file, ∨ Single file, a line of men marching one behind another; a single row. -- On file, preserved in an orderly collection. -- Rank and file. (a) The body of soldiers constituing the mass of an army, including corporals and privates. Wilhelm. (b) Those who constitute the bulk or working members of a party, society, etc., in distinction from the leaders.

 

© Webster 1913.


File (?), v. t. [imp. & p. p. Filed (?); p. pr. & vb. n. Filing.]

1.

To set in order; to arrange, or lay away, esp. as papers in a methodical manner for preservation and reverence; to place on file; to insert in its proper place in an arranged body of papers.

I would have my several courses and my dishes well filed. Beau. & Fl.

2.

To bring before a court or legislative body by presenting proper papers in a regular way; as, to file a petition or bill.

Burrill.

3. Law

To put upon the files or among the records of a court; to note on (a paper) the fact date of its reception in court.

To file a paper, on the part of a party, is to place it in the official custody of the clerk. To file, on the part of the clerk, is to indorse upon the paper the date of its reception, and retain it in his office, subject to inspection by whomsoever it may concern. Burrill.

 

© Webster 1913.


File, v. i. [Cf. F. filer.] Mil.

To march in a file or line, as soldiers, not abreast, but one after another; -- generally with off.

To file with, to follow closely, as one soldier after another in file; to keep pace.

My endeavors Have ever come too short of my desires, Yet filed with my abilities. Shak.

 

© Webster 1913.


File (?), n. [AS. feol; akin to D. viji, OHG. fila, fihala, G. feile, Sw. fil, Dan. fiil, cf. Icel. l, Russ. pila, and Skr. pi to cut out, adorn; perh. akin to E. paint.]

1.

A steel instrument, having cutting ridges or teeth, made by indentation with a chisel, used for abrading or smoothing other substances, as metals, wood, etc.

⇒ A file differs from a rasp in having the furrows made by straight cuts of a chisel, either single or crossed, while the rasp has coarse, single teeth, raised by the pyramidal end of a triangular punch.

2.

Anything employed to smooth, polish, or rasp, literally or figuratively.

Mock the nice touches of the critic's file. Akenside.

3.

A shrewd or artful person.

[Slang]

Fielding.

Will is an old file spite of his smooth face. Thackeray.

Bastard file, Cross file, etc. See under Bastard, Cross, etc. -- Cross-cut file, a file having two sets of teeth crossing obliquely. -- File blank, a steel blank shaped and ground ready for cutting to form a file. -- File cutter, a maker of files. -- Second-cut file, a file having teeth of a grade next finer than bastard. -- Single-cut file, a file having only one set of parallel teeth; a float. -- Smooth file, a file having teeth so fine as to make an almost smooth surface.

 

© Webster 1913.


File, v. t.

1.

To rub, smooth, or cut away, with a file; to sharpen with a file; as, to file a saw or a tooth.

2.

To smooth or polish as with a file.

Shak.

File your tongue to a little more courtesy.Sir W.Scott.

 

© Webster 1913.


File, v. t. [OE. fulen, filen, foulen, AS. flan, fr. fl foul. See Foul, and cf. Defile, v.t.]

To make ful; to defile.

[Obs.]

All his hairy breast with blood was filed.Spenser.

For Banquo's issue have I filed mind.Shak.

 

© Webster 1913.

Log in or register to write something here or to contact authors.