Show image file size limit on user#preference page

Maybe because they don’t give limitation to the file size of uploaded image

Are you sure? Did you try uploading a 20mb image there?

I just uploaded an image with size 26,588,644 bytes (26.6 MB on disk) and succeed.
I also just found this page, facebook says that the limit is 25MB.


Can you try again with an image which is at least 30MB? Depending on the filesystem, the size of the file can vary slightly and a 26MB image might actually only require a bit less than 25MB on another filesystem :wink:

(They might be automatically downsizing images too)

I just uploaded an image from this page, I picked world.topo.bathy.200406.3x21600x21600.C1.jpg image, they say that is 36 MB, but on my laptop the size is 88,661,060 bytes (88.7 MB on disk), however the result is succeed, it’s on my fb


So they don’t actually enforce a limit. Interesting :thinking:

Thanks for doing the work.


It makes sense mentioning the file size limit . A forum is not like facebook , twitter in many way

yes agreeed
but sometimes Discourse’s image compressor able to compress the image file
into significant smaller size
e.g.: the file size limit is 10MB, and an user uploaded 15 MB image, then
validation status will depend on image compressor, is it succeeds or not to
compress the image until under 10MB

This issue is very real in my community. What is odd is that people in low bandwidth countries often try to upload a big file to discourse, it fails, then they email it to me using Gmail and ask me to post it for them. I then resize it myself before uploading and it works. Go figure.

So maybe Gmail has a more failsafe upload system for large files?

Is there no way to have the client check the file size and complain if it is big, eg more than 1mb, then give a warning before proceeding?

There is the HTML5 File API eg. from

<!DOCTYPE html>
<meta charset="UTF-8">
<title>File(s) size</title>
function updateSize() {
  var nBytes = 0,
      oFiles = document.getElementById("uploadInput").files,
      nFiles = oFiles.length;
  for (var nFileId = 0; nFileId < nFiles; nFileId++) {
    nBytes += oFiles[nFileId].size;
  var sOutput = nBytes + " bytes";
  // optional code for multiples approximation
  for (var aMultiples = ["KiB", "MiB", "GiB", "TiB", "PiB", "EiB", "ZiB", "YiB"], nMultiple = 0, nApprox = nBytes / 1024; nApprox > 1; nApprox /= 1024, nMultiple++) {
    sOutput = nApprox.toFixed(3) + " " + aMultiples[nMultiple] + " (" + nBytes + " bytes)";
  // end of optional code
  document.getElementById("fileNum").innerHTML = nFiles;
  document.getElementById("fileSize").innerHTML = sOutput;

<body onload="updateSize();">
<form name="uploadForm">
<p><input id="uploadInput" type="file" name="myFiles" onchange="updateSize();" multiple> selected files: <span id="fileNum">0</span>; total size: <span id="fileSize">0</span></p>
<p><input type="submit" value="Send file"></p>

Not the best support, but not all that bad either

1 Like

Hi @tobiaseigen, @Mittineague
Please take a look at Jeff comments on my pull request at github regarding this issue


this is back again on my site. people really struggle with this why not indicate a file size limit on the picture upload page? Or (better) sort of better error handling when a picture upgrade fails?

Here’s what people commonly see on my site. See screenshot sent to me by a member of my site.

1 Like

@zogstrip we probably want some sort of error here if people upload a gigantic avatar, can you confirm it is in place?


We removed any kind of client-side warning when uploading an image since we’re trying to downsize it on the server.

What happens if you try to upload a 40mb file? Does the user get any kind of feedback that it is hosed?

This on a 20mb file, and that was a .wmv which I renamed, so it might not be a bad idea to check the file header to see if it matches the extension.


In my screenshot example above, it was a 8mb file (a photo being uploaded as profile pic) that caused the upload interface to just hang, without an error notification of any kind. Incidentally this time it was on a normal connection in Washington DC, not like the situation we ran into last summer in Tanzania. There I assumed it was mostly because of slow connections.

Can you reproduce the error condition here?

I just tried uploading the same 3.5mb .jpg to my sandbox, and here on meta. Neither complained about the upload being oversized.

On my sandbox (last update about an hour ago) the save changes button was still dim after 6 minutes (counting after the upload reached 100%).

Here on meta the Save Changes button works after about 5 sec.

Did the same with an 8mb .jpg, same results (meta took about 7 sec before save changes with the larger file).

1 Like

I just uploaded the 8mb profile pic here and it worked - but it did take a while to complete after the “Uploading 100%” indication was displayed, maybe 15-20 seconds. Perhaps my colleague in DC just wasn’t patient enough.

1 Like