About Windows executable files
The registered type is application/vnd.microsoft.portable-executable, but servers usually send application/x-msdownload or application/octet-stream. Browsers warn about or block uncommon executables regardless of type; signing them with a code-signing certificate is what builds trust with SmartScreen.
Other types seen for these files:
application/x-msdownload
,
application/x-msdos-program
,
application/octet-stream
. Accept them when reading uploads, but send application/vnd.microsoft.portable-executable yourself.
File signature
EXE files start with 4D 5A ("MZ"). The extension and the type a browser reports for an upload both
come from the file name, so check these bytes on the server before trusting a file.
Serve .exe with the right Content-Type
Content-Type: application/vnd.microsoft.portable-executable
application/vnd.microsoft.portable-executable exe dll;
AddType application/vnd.microsoft.portable-executable .exe .dll
@exe path *.exe *.dll
header @exe Content-Type "application/vnd.microsoft.portable-executable"
curl -sI https://example.com/file.exe | grep -i '^content-type'
# Content-Type: application/vnd.microsoft.portable-executable
Set the type in code
res.set('Content-Type', 'application/vnd.microsoft.portable-executable');
// Or make the browser download it:
res.attachment('file.exe');
import mimetypes
mimetypes.add_type('application/vnd.microsoft.portable-executable', '.exe') # if your system doesn't know it
mimetypes.guess_type('file.exe')[0] # 'application/vnd.microsoft.portable-executable'
mime.AddExtensionType(".exe", "application/vnd.microsoft.portable-executable")
w.Header().Set("Content-Type", "application/vnd.microsoft.portable-executable")
Accept .exe uploads
<input type="file" accept=".exe,.dll,application/vnd.microsoft.portable-executable">
The accept attribute only filters the file picker; users can still choose another file. Listing the
extension as well as the type matters, because operating systems don’t always report the type you expect.
Related types
-
.bin (
application/octet-stream): Binary data -
.zip (
application/zip): ZIP archive -
.apk (
application/vnd.android.package-archive): Android package
More programs and binaries
.jar . Look up any extension or type with the MIME type lookup.
Sources
Spotted a mistake? Email hello@devtoolsmith.com and we’ll fix it.
Frequently asked questions
What is the MIME type for .exe files?
application/vnd.microsoft.portable-executable. You may also see application/x-msdownload, application/x-msdos-program, application/octet-stream, which are older or unofficial; send application/vnd.microsoft.portable-executable. The full header is "Content-Type: application/vnd.microsoft.portable-executable".
Why does my server send the wrong Content-Type for .exe?
Web servers pick the type from the file extension using a table (mime.types in nginx and Apache). If .exe is missing from that table, they send a default such as application/octet-stream or text/plain. Add the mapping as shown on this page, then check the response with "curl -sI".
How can I check that a file really is EXE?
Look at the first bytes rather than the extension or the type the browser reports, which both come from the file name. EXE files start with 4D 5A ("MZ"). The MIME type lookup on this site reads them for you when you drop a file on it.