WEBVTT

0
00:00.300 --> 00:06.960
We are cruising through this, but let's soldier on. The next attribute I want us to talk about is the...

1
00:06.960 --> 00:14.760
accept attribute. The accept attribute is a space and/or comma separated list of content types or what's

2
00:14.760 --> 00:19.710
known as internet media types that a server is supposed to handle correctly.

3
00:19.960 --> 00:26.700
It looks like this. Say you only wanted the user to upload an image or JPEG file. And to reiterate, it...

4
00:26.700 --> 00:30.180
tells the server what type of files it can

5
00:30.180 --> 00:36.680
accept. This can be useful when uploading files, for example, to filter on the client side the types

6
00:36.690 --> 00:39.510
that the server shouldn't be able to handle.

7
00:39.870 --> 00:45.720
And this accept attribute is only really applicable with forms. It doesn't really apply to other HTML

8
00:45.720 --> 00:49.830
elements. But ... ding ding ding ... redundancy alert.

9
00:50.580 --> 00:57.560
This attribute has been removed, or what's known as "deprecated" since HTML5 came out.

10
00:57.870 --> 00:59.040
But don't panic.

11
00:59.040 --> 01:01.170
We're not just learning about it for the sake of it.

12
01:01.560 --> 01:08.520
Although HTML5 has removed it, it is still in favor of you using the attribute on other form controls,

13
01:08.700 --> 01:14.640
specifically on the input type file control. So we can still use it there.

14
01:15.150 --> 01:21.450
Importantly, though, the accept attribute does not validate the type of selected file.

15
01:21.630 --> 01:28.240
It simply provides hints for browsers to guide users towards selecting that correct file type.

16
01:28.680 --> 01:34.050
What this means is that it's still possible for users to toggle an option in the file chooser...

17
01:34.290 --> 01:40.170
that makes it possible to override this and select any file they wish and even upload an incorrect file...

18
01:40.170 --> 01:40.530
type.

19
01:40.860 --> 01:46.220
But we're going to get more to that later when we discuss this input type in a bit more detail. For now...

20
01:46.320 --> 01:52.250
just realized that on the form element itself, this accept attribute has been removed.

21
01:52.260 --> 01:54.840
You shouldn't use it directly on the form element.

22
01:55.330 --> 01:56.070
Let's move on.