Forum Discussion
Melissa Klug
Nov 22, 2017Copper Contributor
Open HTML files in browser - SharePoint Online
I'm trying to open HTML files that are saved in a Document Library created on a Team site (using Office 365 Groups). When we add HTML files to the library they will only download and then open. We wo...
KuBra9000
Jan 27, 2021Copper Contributor
For those of us who are still onpremise.
Add the html mime type to the WebApplication in SharePoint and use a document library in classic mode. Not sure if Microsoft let's you do this in SharePoint Online.
You can use the script to add any mime type.
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue
$webApp = https://yoursitename.com
function Add-SPAllowedInlineDownloadedMimeType{
[CmdLetBinding()]
param(
[Parameter(Mandatory=$true, Position=0, ValueFromPipeLine=$true)]
[Microsoft.SharePoint.PowerShell.SPWebApplicationPipeBind]$WebApplication,
[Parameter(Mandatory=$true, Position=1)]
[string]$MimeType
)
process{
$actualWebApp = $WebApplication.Read()
if ($actualWebApp.AllowedInlineDownloadedMimeTypes -notcontains $mimetype)
{
Write-Host "Adding MIME Type..."
$actualWebApp.AllowedInlineDownloadedMimeTypes.Add($mimetype)
$actualWebApp.Update()
Write-Host "Done."
} Else {
Write-Host -ForegroundColor Green "MIME type is already added."
}
}
}
Add-SPAllowedInlineDownloadedMimeType -WebApplication $webApp -MimeType "text/html"