Topic: Maximum file size 0 MB

When I set in conf.php
define("MAXIMUM_SIZE",500000);        // bytes
it shows the file size as 0 MB on the board.

How can I show it either as 0.5MB or in KB?

2

Re: Maximum file size 0 MB

In includes/post.php, line 406, change this:

        $vars["max_bytes"] = round(MAXIMUM_SIZE/1024/1024);

to this:

        $vars["max_bytes"] = number_format(MAXIMUM_SIZE/1024/1024,1);

This will give you precision to the tenths (ie "0.5"). If you change that last number from 1 to 2, you get hundredths (ie "0.50"), etc.

If you want to change it to KB, then change it to:

        $vars["max_bytes"] = round(MAXIMUM_SIZE/1024);

and then change the display line in templates/post.tmpl where it specifies "MB" to "KB".

3 (edited by Kolya 2007-01-25 17:28:25)

Re: Maximum file size 0 MB

Thank you. I'll try this out.

EDIT: Yeap, works good. I also changed templates/post.tmpl to read KB now.



Something I just noticed:
In the Readme it says:
   /mods
           Moderator features are available here: managing bans. To access ...

While the real adress is /mod
Didn't want to make a new thread for this.

4

Re: Maximum file size 0 MB

Oops, thanks.

5 (edited by Kolya 2007-01-26 14:31:06)

Re: Maximum file size 0 MB

I changed it to KB but now it doesn't realise when the image is to big anymore. It seems to try to upload the image then just makes the post without the image. No warning, no nothing. :/

Works with decimal fractions of MB though "0.5 MB" looks a bit silly. I want KB!

6

Re: Maximum file size 0 MB

There isn't a warning- there's no way for the pre-submit checks to get at the size of the file, so it will post anyway. Once it hits the server, there should be some sort of error- something I fixed in 1.1 I thought.

Re: Maximum file size 0 MB

Sorry, my mistake. It's not related to the MB/KB.

Sometimes I get a warning:
"No file upload detected - please make sure your post wasn't empty and that you didn't exceed the maximum file size for upload (512000 bytes)"
That happens only if there was no comment in the post it seems.
If there was a comment it just posts that comment. And that was where I missed that warning. But it shouldn't post at all I think because obviously something went wrong and the outcome won't please a user who tried to upload. If he just wanted the text he could just post text after all.

Re: Maximum file size 0 MB

This can lead to odd posts, where somebody comments on a nonexistent picture he meant to upload but was rejected.

9

Re: Maximum file size 0 MB

Hmm, see if this works for you

--- release/ochiba-1.1/includes/post.php      2006-01-07 11:40:39.000000000 -0800
+++ includes/post.php   2007-01-28 13:01:49.000000000 -0800
@@ -110,6 +110,8 @@
                 $page->fail($ERRORS["restricted"]);
             }
         }
+    } else if ($_FILES['file']['name'][0] && !is_uploaded_file($_FILES['file']['tmp_name'][0])) {
+        $page->fail($ERRORS["emptyreject"]);
     }
 
     // Quit now if errors ...

Re: Maximum file size 0 MB

Hey, much better now! :)
It throws the "No file upload detected ..." error.
Well done.