Trusted WordPress tutorials, when you need them most.
Beginner’s Guide to WordPress
WPB Cup
25 Million+
Websites using our plugins
16+
Years of WordPress experience
3000+
WordPress tutorials
by experts

Så här ökar du den maximala storleken för filuppladdning i WordPress

Har du någonsin försökt att ladda upp en fil till din WordPress-webbplats och stött på patrull? Det är superfrustrerande när du inte kan ladda upp den bild, det plugin eller det tema du behöver. Våra läsare ber oss ofta om hjälp med filuppladdningsproblem eftersom de kan få ditt arbetsflöde att krypa.

Ibland kan dessa filuppladdningsgränser oväntat hindra dig från att lägga till innehåll i ditt mediebibliotek eller installera de större plugins och teman du behöver. Det är som att vara fast med händerna bundna. Och det är ännu mer irriterande när du inte vet hur du ska fixa det!

Men oroa dig inte, vi finns här för att hjälpa till. Vi älskar att WordPress är en så konfigurerbar plattform och att det ofta finns flera sätt att lösa samma problem.

I den här guiden visar vi dig de enklaste sätten att öka den maximala filuppladdningsstorleken i WordPress. Vi tar dig förbi dessa begränsningar så att du kan återgå till att göra det du älskar – att driva din webbplats!

How to increase the maximum file upload size in WordPress

Varför öka den maximala storleken för filuppladdning i WordPress?

Din hosting provider för WordPress kommer att ange en standard för maximal storlek för upload av filer när du registrerar dig och installerar WordPress. Din hosting provider definierar denna limit, och den varierar vanligtvis från 2 MB till 500 MB.

För de flesta WordPress website ägare kommer denna limit att vara mer än tillräckligt.

Det finns dock tillfällen då du måste höja denna limit så att du inte runar in i upload errors.

Till exempel:

Med detta sagt, låt oss visa dig hur du kan öka den maximala storleken på filuppladdare på din WordPress site.

Note: Tänk på att om du displayed många stora filer på din website kan det allvarligt sakta ner dess hastighet och prestanda. Därför rekommenderar vi normalt att du aldrig uppladdar videoklipp till WordPress.

Eftersom de flesta användare har olika WordPress inställningar för webbhotell, kommer vi att täcka följande:

Så här kontrollerar du din limit för maximal storlek på filuppladdning i WordPress

WordPress visar automatiskt limiten för maximal filuppladdningsstorlek när du laddar upp images eller andra media.

För att kontrollera detta, gå bara till Media ” Add New i din WordPress adminpanel, och du kommer att se den maximala filuppladdningsstorlekslimiten för din WordPress site.

Check current file upload size limit

Nu när du vet hur du hittar storlekslimiten ska vi visa dig hur du ökar den maximala storleken för upload i WordPress.

Metod 1: Kontakta din hosting provider för WordPress

Ett av de enklaste sätten att öka den maximala storleken för upload av filer i WordPress är att kontakta din WordPress hosting provider.

Detta är en relativt enkel uppgift för deras kundtjänst och kan göras på ett par minuter.

För Beginner kan detta vara mycket enklare än att lägga till kod i WordPress och editera server-filer.

Helt enkelt head över till din hosting providers website, gillar Bluehost, och logga in.

Klicka sedan på ikonen “Chatt” längst ner på vyn. Du kan sedan be de anställda på supporten att öka storleken på filuppladdningen på din site i WordPress.

Clicking the Bluehost live chat support button in the dashboard

You can also reach out to support from inside your hosting account dashboard.

Metod 2: Skapa eller edit en befintlig php.ini-fil

Ett annat sätt att öka den maximala storleken på filuppladdningen är att skapa eller editera en fil som heter php.ini. Denna fil kontrollerar många settings för ditt WordPress webbhotell.

De flesta hosting providers för WordPress gillar Bluehost och har en nybörjarvänlig cPanel som hjälper dig att hantera din website.

Om din server har en cPanel dashboard kan du öka storleken på upload av filer med hjälp av de inbyggda tools.

Note: Följarna är från Bluehost cPanel. De flesta shared hosting providers kommer dock att ha liknande steg.

Du hittar en cPanel-knapp längst ner på tabben Webbhotell i Bluehost.

Open cPanel in Bluehost

Om du klickar på den här knappen öppnas din cPanel dashboard.

Nu måste du rulla ner till Software section och klicka på “MultiPHP INI Editor”.

MuliPHP INI Editor in Bluehost's cPanel

Därefter rullar du ner till sektionen märkt “upload_max_filesize” och enter en new maximal filstorlek i boxen.

Klicka sedan på knappen “Tillämpa”.

Upload Max Filesize Setting

Alternativt kan du clicka på menu tabs “Editor Mode”, och då kan du ändra den maximala storleken för uppladdare direkt i editorn.

You need to edit the ‘upload_max_filesize’ section to increase your file upload size.

När du är slutförd klickar du bara på knappen “Save”.

Change max upload filesize in code editor

Edit php.ini genom att lägga till kod

Om din nuvarande hosting provider inte erbjuder alternativet cPanel, måste du editera den här filen manuellt.

För att göra detta kan du använda en FTP-klient eller alternativet filhanterare i kontrollpanelen på ditt WordPress webbhotell.

Om du använder ett delat webbhotell kanske du ej ser php.ini-filen i din directory. Om du inte ser någon, skapar du helt enkelt en fil med namnet php.ini och uploadar den till din root folder.

Add sedan följande code snippet till filen:

upload_max_filesize = 256M
post_max_size = 256M
max_execution_time = 300

Du kan ändra limiten “256M” till den filstorlek som du behöver för din WordPress blogg.

Metod 3: Add Code to Your WordPress Theme functions.php File

Denna metod innebär att du lägger till kod i din functions.php-fil i ditt WordPress theme.

Istället för att editera filen direkt rekommenderar vi att du använder WPCode. Det är det bästa code snippets plugin som allow you to add code to your website without breaking it.

Om du inte har gjort det tidigare kan du läsa vår guide för nybörjare om hur du lägger till customize-kod i WordPress.

Först måste du installera det gratis pluginet WPCode. För mer detaljer, se vår Step-by-Step guide om hur du installerar ett WordPress plugin.

Efter aktivering ska du navigera till Code Snippets ” + Add Snippet.

Du måste hålla muspekaren över alternativet “Add Your Custom Code (New Snippet)” och sedan klicka på knappen “+ Add Custom Snippet”.

Add new snippet

Därefter måste du välja “PHP Snippet” som kodtyp från listan med alternativ som visas.

Select the PHP snippet option

På följande skärm anger du ett namn för din nya snippet, som kan vara vad som helst för att hjälpa dig att komma ihåg vad koden är till för.

Sedan kan du kopiera och klistra in följande kodsnutt under “Code Preview”. Se till att du ändrar “256M” till den maximala filstorlek du behöver:

@ini_set( 'upload_max_size' , '256M' );
@ini_set( 'post_max_size', '256M');
@ini_set( 'max_execution_time', '300' );
Save Your Custom Snippet in WPCode

Till sist togglar du högst upp till “Active” och klickar sedan på knappen “Save Snippet”. Koden kommer nu att köras på din website.

Metod 4: Add Code till din .htaccess-fil

Ett annat sätt att öka den maximala filstorleken är att ändra .htaccess-filen. Denna fil kontrollerar konfigurationsinställningarna på hög nivå för din website.

För att göra detta måste du logga in på din website server via FTP. Om du inte har gjort det tidigare kan du läsa vår guide för nybörjare om hur man använder FTP för att uploada filer till WordPress.

Efter det måste du lokalisera din .htaccess-fil i din websites root folder.

Open .htaccess file

Om du inte kan hitta din .htaccess-fil kan den vara dold av din filhanterare eller FTP-klient. För att lära dig mer, se vår guide om varför du inte kan hitta .htaccess-filen på din WordPress site.

Följer du detta måste du add to följande code snippet till din .htaccess fil:

php_value upload_max_filesize 256M
php_value post_max_size 256M
php_value max_execution_time 300
php_value max_input_time 300

Om du vill öka storleken på din maximala upload av filer ännu mer ändrar du bara “64M” till den storlek som du behöver.

Metod 5: Använd ett tillägg till WordPress för att öka storleken på filuppladdningen

Ett annat sätt du kan öka limiten för maximal upload av filer är genom att använda WP Increase Upload Filesize plugin. Om du inte är bekväm med att lägga till kod i WordPress, kan detta vara ett bra alternativ för dig.

Det första du behöver göra är att installera och aktivera pluginet. För mer detaljer, se vår guide om hur du installerar ett plugin för WordPress.

Efter aktivering, navigera till Media ” Increase Upload Limit i din WordPress adminpanel.

Detta leder dig till en vy där du kan selecta en new storlek för upload i rullgardinsmenyn “Choose Maximum Upload File Size”.

Klicka sedan på knappen “Save Changes”.

Increase file upload size with plugin

Note: Den maximala storleken för upload av filer ställs in av din hosting provider. Om du behöver en filstorleksgräns som är större än den som anges i rullgardinsmenyn måste du kontakta din hosting provider och be att få öka limiten.

Video Tutorial

Om du inte tycker om att följa skriftliga instruktioner kan du istället titta på vår videohandledning:

Subscribe to WPBeginner

Vi hoppas att den här artikeln hjälpte dig att öka den maximala filuppladdningsstorleken i WordPress. Du kanske också vill se vår guide om hur du lägger till ytterligare filtyper som kan laddas upp i WordPress och våra expertval av plugins och tips för att förbättra WordPress adminområde.

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.

Disclosure: Our content is reader-supported. This means if you click on some of our links, then we may earn a commission. See how WPBeginner is funded, why it matters, and how you can support us. Here's our editorial process.

The Ultimate WordPress Toolkit

Get FREE access to our toolkit - a collection of WordPress related products and resources that every professional should have!

Reader Interactions

406 kommentarerLeave a Reply

  1. I am unable to import my blogger exported xml file to wordpress.
    My blogger imported xml file size is 24 mb.
    Please solve this problem, i shall be thankful to you.

  2. Has anyone ever told you that the copy and paste YOUR code all throughout your site always has the:

    1: code
    2: code
    3: code

    So it’s a bit of a edit to get it to work right when a simple copy/paste would be stressfree for your readers! Just sayin…

    • Thanks! This is the only thing that worked for me. Worth noting, I already had a php5.ini file in there w/ the same code, it did nothing. A tad confusing.

  3. After 2 hours of frustration, the htaccess method mentioned here worked out for my local environment.

    Thank you very much. :)

  4. I change my .htaccess and put

    php_value memory_limit 2G
    php_value upload_max_filesize 2G
    php_value post_max_size 2G
    php_value max_execution_time 99999
    php_value max_input_time 99999

    when I go for upload a fine it shows 2GB but when I upload any file that larger then 128MB it shows HTTP error. Need help please.

    Thanks

  5. I add on my .htaccess

    php_value memory_limit 2G
    php_value upload_max_filesize 2G
    php_value post_max_size 2G
    php_value max_execution_time 99999
    php_value max_input_time 99999

    and it shows 2GB but when I upload larger then 128M file it gives me HTTP error. can anyone help me please.

    Thanks

  6. I DO NOT recommend putting that code in the Theme Functions file. I tried it and it completely blew up my site. And if you don’t know how to use FTP or the File manager to change the Functions file BACK, you’ll be very unhappy. I haven’t tried the other options but if I find something that works I’ll let you know :)

    • Hello Elisabeth,ive tried it and it has also blown up my site,i cant acces it…may i please know how you fixed it?

  7. Just contacted godaddy. I am using cpanel hosting through them. He added a file .user.ini in the public/html file with the following:

    memory_limit = 128M
    max_execution_time = 300
    post_max_size = 128M
    upload_max_filesize = 256M

  8. in the .htaccess solution, where in the file do you enter the code, i put it at the end and got a 500 error?

  9. I heard as an alternative you could just directly upload via the ftp cpanel, but when I do that the PDF does not show up in my WP media dashboard?

    • Hi Cornelius,

      You can upload a PDF file but yes you are right it will not be visible in the Media library on your WordPress site. To see a file in the media library and be able to easily add it, you would need to upload it using the built in media uploader.

      Admin

      • You can upload anything via FTP/SFTP and then add it to the database using a plugin like Add From Server.

  10. This worked for me (as nothing else would):

    – Open wp-config.php
    – At the very bottom add this line:

    define(‘WP_MEMORY_LIMIT’, ‘128M’);

    – Save (and upload your file)

  11. So i’m not a developer so i dont feel like messing with php and some functional stuff.
    i found from a post above php settings and all is set right, max file size is 30MB so i’m confused why i still can’t upload media bigger than 5mb.
    is there a wordpress thing that i’m missing
    i didn’t find anywhere place to change that,

  12. If you are using cPanel most of the time you edit via the PHP Version settings, you can check if you are on 5.6 or 7.0 and edit all the settings via cpanel. For me this is the only way my host has all the others locked down, but its real handy and there are simple ways to enable PHP modules and tweak any setting.

  13. Thanks.

    This is what finally worked for me:

    In wp-config, before wp-settings:

    define( ‘WP_MEMORY_LIMIT’, ‘256M’ );
    define( ‘WP_MAX_MEMORY_LIMIT’, ‘256M’ );
    ini_set( ‘memory_limit’, ‘256M’ );

    In .htaccess:

    php_value memory_limit 256M
    php_value upload_max_filesize 64M
    php_value post_max_size 64M
    php_value max_execution_time 300
    php_value max_input_time 300

  14. Hello

    I am building a woocommerce store for selling audio files. Some of my files are over 100MB so uploading straight from wordpress wont work. What I am trying to do is Upload the file to cpanel and than post that link in the downloadable product on WP. But I dont know how to do it. I view the file in cpanel and copy that link but that just takes the person to cpanel login. I dont know hot to get the link of my file in cpanel so others can download it when they buy a product?

    Do you have a tutorial on this?

    or can you help?

    Thanks

    • You would need to look more into this because you would need security for that file url, generally the file url is accessible to everything and therefore can be downloaded without making a purchase.

  15. Absolutely DO NOT try to enter that code into the Theme Functions file!!!!! Now I am getting error messages and can’t get to the dashboard for my site. I won’t DARE try any of their other suggestions.

  16. Thanks. the .htaccess version worked for me. I just had to remember to show hidden files in my cpanel file manager.

  17. Just wanted to say thanks. I’ve been able to solve three wordpress related issues in one day, all with help from this website. Kudos on the good work. :D

  18. Thanks.
    The php.ini edits helped. I had to make sure to also up the post_max size as well. I failed to edit this on first update, and nothing changed. Edit all parameters and presto. Thanks again!

  19. It was great. Very helpful! Had to upload a theme, used the second method. added a ner php.ini file and the theme is installed. Thanks a lot :)

  20. Thanks for helping

    making the changes in the .htaccess method made the website crash
    however changing the php.ini file worked for me.

  21. or try another method like mine,

    on cpanel > click the “select php version” > then click “switch to php options” > find the “upload_max_filesize” then change it whatever you want.

  22. ‘upload_max_size’ is not a php.ini variable name. it’s ‘upload_max_filesize’. that’s stated wrong in solution 1

  23. I tried your first suggestion, and apparently threw some bad code into the functions.php file and now I have lost access to my website’s dashboard, the actual website cannot be accessed by anyone, and the problem is obviously not solved.

  24. Hi, where i should put that code to my .htaccess file.
    I have tried put this code to my htaccess file but it always 500 internal server error when i open my live site.

    # BEGIN WordPress

    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ – [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]

    php_value max_input_vars 5000
    php_value max_execution_time 300
    php_value post_max_size 50M

    # END WordPress

    • Try this:

      php_value upload_max_filesize 50M
      php_value post_max_size 50M
      php_value max_execution_time 300
      php_value max_input_time 300

  25. Hi,

    I have used the first method of adding code to child theme functions.php file, but it does not have the desired effect. In localhost, the limit is 3 MB and in shared server, the limit is 32 MB. Any idea why it is happening so?

    Thanks.

  26. i have followed this even contacted my host increased my uploads to 64mb however in wordpress it still only allows 8mb.
    any other suggestions please help.

  27. Same problem for wordpress 3.9 / 4 version and having a look to Chrome console or firefox I saw an error 413 of NGINX when uploading

    Maybe this thread can help to nginx users ;)

Leave A Reply

Thanks for choosing to leave a comment. Please keep in mind that all comments are moderated according to our comment policy, and your email address will NOT be published. Please Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.