Du kan uploada många vanliga filtyper i WordPress, inklusive images, videoklipp, ljudfiler och Office-filer. Vissa website-ägare behöver dock uploada filer som inte stöds.
Under årens lopp har många av våra läsare till exempel frågat oss hur de kan ladda upp SVG och andra filtyper till WordPress. Därför letade vi efter ett nybörjarvänligt sätt att göra detta.
I den här artikeln visar vi dig hur du kan add to ytterligare filtyper för upload i WordPress.
Vilka filtyper är tillåtna för upload i WordPress?
Av säkerhetsskäl kan du bara ladda upp de vanligaste filtyperna till din WordPress-webbplats eller WooCommerce-butik. Det finns också en maximal storleksgräns för de filer som kan laddas upp.
Som standard är de filtyper och utökningar som tillåts:
Images:.jpg, .jpeg, .png, .gif, .ico, .webp
Dokument:.pdf, .doc, .docx, .ppt, .pptx, .pps, .ppsx, .odt, .xls, .xlsx, .PSD, .XML
Ljud:.mp3, .m4a, .ogg, .wav
Videoklipp:.mp4, .m4v, .mov, .wmv, .avi, .mpg, .ogv, .3gp, .3g2
Tips: Även om du kan uploada videoklipp till WordPress rekommenderar vi att du använder ett webbhotell för videoklipp istället. Det skyddar hastigheten och prestandan på din website.
Vissa typer av filer kan dock missbrukas och kan utgöra en säkerhetsrisk, så WordPress aktiverar dem inte som standard.
Här är en lista över filtyper som blockeras av WordPress:
Images som t.ex. .svg, .bmp
Dokument gillar .psd, .ai, .pages
Kodfiler som .css, .js, .json
Videoklipp som .flv, .f4l, .qt
Om du försöker add new filtyper som inte stöds till din WordPress site, kommer du att se error message,”Ledsen, you are not allowed to upload this file type”.
Men vad händer om du behöver ladda upp ett filformat som inte stöds? Du kan ladda upp filerna via FTP eller din WordPress-hosts filhanterare, men det är inte lika bekvämt som att använda det inbyggda WordPress-mediebiblioteket eller ett formulär för filuppladdning.
Tips: Om du vill ladda upp bilder med SVG-tillägget kan du kolla in vår guide om hur du lägger till SVG-filer i WordPress.
Låt oss ta en titt på hur du kan add to ytterligare filtyper som kan uploadas i WordPress.
Så här addar du till ytterligare filtyper som kan uppladdas i WordPress
Vissa handledningar kommer att berätta för dig att redigera din functions.php-fil
och lägga till en PHP-kodsnutt där. Vi tycker dock att det enklaste och säkraste sättet att aktivera olika filtyper är med ett enkelt plugin.
Först måste du installera och aktivera det gratis pluginet File Upload Types by WPForms. För mer detaljer, se vår Step-by-Step guide om hur du installerar ett WordPress plugin.
Det är ett av de bästa tilläggen för filuppladdning och är det enklaste sättet att add to support för ytterligare filtyper till WordPress. Det skapades av WPBeginners grundare, Syed Balkhi.
Använda Preset filtyper
Efter aktivering måste du gå till sidan Inställningar ” Filuppladdningstyper i ditt WordPress-adminområde. Sedan kan du helt enkelt bläddra igenom listan över förinställda filtyper eller ange en filtyp i sökrutan.
Därefter kontrollerar du boxarna bredvid de filtyper som du vill aktivera.
När du är klar kan du klicka på knappen ”Save Settings” längst ned på skärmen för att spara dina ändringar.
Nu kommer du att kunna uploada dessa filtyper med hjälp av WordPress mediabibliotek.
Lägga till customize filtyper
Om den filtyp du vill add to inte finns med i listan över Presets kan du lägga till den som en customize filtyp.
När du rullar längst ner på vyn Typer av filuppladdning kommer du till en section med rubriken ”Add Custom File Types”. Här kan you add a new file type by entering a description, MIME type, and file extension.
Om du vill add to en annan customize filtyp klickar du bara på ’+’ icon i slutet av raden. När du är klar, glöm inte att klicka på knappen ”Save Settings” för att store dina ändringar.
Om du t.ex. vill add to filtypen YAML skriver du ”YAML file” i description, ”text/yaml” i fältet MIME type och ”.yaml” som utökning av filen.
MIME (”Multipurpose Internet Mail Extension”) är ett standardiserat sätt att identifiera filer på webben. Det enklaste sättet att lära sig en fils MIME-typ är att använda en MIME File Type Checker.
Vi hoppas att denna handledning hjälpte dig att lära dig hur du lägger till ytterligare filtyper som kan laddas upp i WordPress. Du kanske också vill lära dig hur du skapar ett filuppladdningsformulär i WordPress eller kolla in vår lista över de bästa plugins och tips för att förbättra WordPress adminpanel.
If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.
Rob
Worked wonders! Saved me hours, thanks for this!
WPBeginner Support
Glad our guide was helpful!
Administratör
Richard
Can i have a virtual store on my eCommerce wp website?
WPBeginner Support
You are able to have a store on your site if you want
Administratör
Reinette
If this is a beginner’s tutorial then I would need the pre-beginner tutorial
All I want to do is upload .mobi and .epub files to my Woocommerce store and I can´t find any help that I’m able to understand. Why is this so difficult?!
WPBeginner Support
For making adding the code easier you may want to take a look at our guide here:
https://www.wpbeginner.com/beginners-guide/beginners-guide-to-pasting-snippets-from-the-web-into-wordpress/
And you should be able to go through the linked page to find text you need for epub and mobi files
Administratör
kevin kipkirui koech
YEEEES it workd for me to uploa ApK file android apk
her is the code i added at the bottom of functions.php
function my_myme_types($mime_types){
$mime_types[’svg’] = ’image/svg+xml’; //Adding svg extension
$mime_types[’psd’] = ’image/vnd.adobe.photoshop’; //Adding photoshop files
$mime_types[’apk’] = ’application/vnd.android.package-archive’; //Adding apk files
return $mime_types;
}
add_filter(’upload_mimes’, ’my_myme_types’, 1, 1);
WPBeginner Support
Great, glad our guide could help and nice job getting it worked out
Administratör
Ali Hassam
Please make blog on how to make download option in the wordpress.
I hope you understand what I said.If some one click ’download`. It will download.
WPBeginner Support
For what it sounds like you’re wanting, we already have an article here: https://www.wpbeginner.com/plugins/how-manage-track-control-file-downloads-wordpress/
Administratör
ujwal
i have added the below code in functions.php but when i’m trying to upload ’svg’ files,i’m getting the same error. Please help me.
’Sorry, this file type is not permitted for security reasons.’
/********** code used ***************/
//Adding different file format
function my_myme_types($mime_types){
$mime_types[’svg’] = ’image/svg+xml’; //Adding svg extension
return $mime_types;
}
add_filter(’upload_mimes’, ’my_myme_types’, 1, 1);
WPBeginner Support
You would want to reach out to your hosting provider, they are likely overriding the files allowed to be uploaded
Administratör
Kymmie
OMG! You saved me! I followed your instructions and I am now able to upload EPUB files to my form in Request Book Review page on my website. Thank you!
WPBeginner Support
Glad our guide could help
Administratör
Sebastjan
Can you paste your code for epub please? I’m not to good with coding.
Robin
Allow All File Types
You can also setup WordPress to allow to upload all file types. This can be performed with the help of a WordPress constant “ALLOW_UNFILTERED_UPLOADS”. You can set the WordPress constant “ALLOW_UNFILTERED_UPLOADS” to true” in wp-config.php file of your WordPress install. The wp-config.php file can be found in the root directory of your WordPress install. Using your favorite editor (vi editor) open the wp-config.php file and add the following line somewhere in the file. You can also use File Manager to edit the WordPress configuration file.
define(‘ALLOW_UNFILTERED_UPLOADS’, true)
Don’t forget to save the config file after editing.
WPBeginner Support
The dangers of a method like this would be that you are allowing every file type to be uploaded to your site which removes some safety.
rob thirlby
I still cannot get csv uploads to work in 4.9.9 upwards of wordpress. Has anyone got a solution? Just adding the csv type to the list doesn’t seem to help. Is csv explicitly banned in the core somewhere.
Sam Bean
Is all this still good for Wordpress 4.9.2? I also could not find any mime types for Adobe Illustrator files (.AI and .EPS)
Can you tell me what I would add to the file to be able to upload those 2 file types?
Ajeet
hello sir,
i want to upload .exe file,but it shows an error.So what can i do
WPBeginner Support
Hi Ajeet,
You cannot upload it by default. You will need to allow .exe file types first. Please see the instructions in the above article.
Administratör
Ravi Kanani
I want to upload Embroidery Design file .emb
In the page several common file extension .emb is not included.
Please Give me code to upload .emb type of files.
Dan
Kevin’s code for KML/KMZ files worked perfectly for me. Thanks!!!
Jaime
I did what the instructions say and I still can’t upload .ogv files.
I added this code to functions.php:
function my_myme_types($mime_types){
$mime_types[’ogv’] = ’video/ogg’; //Adding ogv extension
return $mime_types;
}
add_filter(’upload_mimes’, ’my_myme_types’, 1, 1);
Does anybody know why it doesn’t work?
loule
same problem for me
Sarah
This worked to allow me to initiate the upload of a dmg file, but when it says the is 100% complete, it doesn’t show up in the Media files, and it isn’t in the wp-content folder either, so I’m not sure why… any ideas?
Alex
How would I go about editing the snippet for android .apk files?
Sajed Shaikh
Hi,
I want to upload .gifv file extension image. For that I have added the following code in functtions.php file.
function my_myme_types($mime_types){
$mime_types[’gifv’] = ’image/gifv’;
return $mime_types;
}
add_filter(’mime_types’, ’my_myme_types’, 1, 1);
File is uploaded successfully but its not playing. Please help.
Dustin
Doing this example I was able to now allow upload of AI file with custom Icon for the file type. I would like to change the icon used for PDF to a PDF icon. Can this be done?
Seems like it just wants to use the default
Amit Saxena
hi,
i m facing same issue still, i added apk extention from function file.
but it shows still same issue.
kindly suggest.
Diana
Thanks for this article, I used it today! I have a question. I had to allow .sql file types to be uploaded to wordpress, in order to upload some of my scripts that I would like to share.
The problem is, if I put the script in a link, when I click on the link, the script downloads automatically, instead of opening in a new window.
This is the code I added:
function my_myme_types($mime_types){
$mime_types[’sql’] = ’text/x-sql’; //Adding sql extension
return $mime_types;
}
add_filter(’upload_mimes’, ’my_myme_types’, 1, 1);
When can I change the behavior? Also after the file is uploaded it says it is SQL type.
Thanks
Diana
Darren
So, it would be nice if we knew where to add the code??????????????????
Thanks
WPBeginner Support
All custom code in the article goes into your theme’s functions.php file or a site-specific plugin
Administratör
Kevin
At the bottom of the functions.php page. At the top? Is there already a place I add them to, like under the allowed file types already there? (jpg,gif,mp4,etc…)
I’ll try at the bottom and see what happens.
Kevin
Worked. For the people wondering. I just scrolled to the end of that page and pasted the code in there. If you copied and pasted the code up there, don’t be like me and leave the numbers. Just erase the numbers.
And if you’re like me, you just skimmed through to find what you’re looking for. I couldn’t find what I had to put so it would open the right program, it’s in that link that’s hidden between the snippets of code up there. ”File extensions” is what you’re looking for. Go to that page and look up your extension you want to add, I wanted to add KML and KMZ for my wiki on a stick and it looks like this…
function my_myme_types($mime_types){
$mime_types[’kml’] = ’application/vnd.google-earth.kml+xml’; //Adding kml extension
$mime_types[’kmz’] = ’application/vnd.google-earth.kmz’; //Adding kmz files
return $mime_types;
}
add_filter(’upload_mimes’, ’my_myme_types’, 1, 1);
All I did was copy and past the code up there and changed the file extension and the… other part. Worked like a charm.
Oh, the finctions.php is in appearance -> Editor -> On the right side of that page, Theme Functions (functions.php). Just scroll to the end of that page and add your code there.
Bruno
Kevin, whats your WP version? Mine is 4.2.4 and it doesnt work!…
Jeremy Taylor
Adding the code looks pretty easy but it is not clear where I should add the code. Where do I go from my dashboard to add it? I’m using Wordpress 4.3.1.
Thanks
Jeremy
Kymmie
Go to Appearance > Editor > Look for functions.php and just add the code to the bottom. Don’t forget to put a label like
//Adding different file format
so you would know.
Bry
Hi There.
Thanks for the really useful information…
I managed to get the different file types (.IES and .LDT files) to upload ok following your advise above but unfortunately they do not download as files, but rather as code….any tips on how to fix this issue?.
Thanks in advance for your help.
Regards
Bry
Bry
This is the code i used in the theme-function.php file..
function my_myme_types($mime_types){
$mime_types[’ies’] = ’application/octet-stream’; //Adding .ies extension
$mime_types[’ldt’] = ’application/octet-stream’; //Adding .ldt extension
return $mime_types;
}
add_filter(’upload_mimes’, ’my_myme_types’, 1, 1);
Sara
THX. That’s useful
WPBeginner Staff
Yes, CSS.
Mark Gandy
How do you get the file type’s small icon (the file type logo) to load automatically where it will be positioned next to the name of the file (which is a link)? I’m guessing that’s CSS?