rejetto forum

Software => HFS ~ HTTP File Server => HTML & templates => Topic started by: skb on July 26, 2015, 01:11:39 AM

Title: Limits to uploaded files by size?
Post by: skb on July 26, 2015, 01:11:39 AM
Is there an easy way to restrict uploads to "small" sizes, e.g. only files less than 100KB?

Can the system know the file size before it is uploading it? Alternatively, is there any way to abort an upload if the file is larger than a limit? Or, perhaps drop it after the upload is complete? Do we know the size when the [upload completed] event happens? Is it possible to delete a large file at that point?

I fear that this question might be answered already, but the terms I tried to search for (like "file size") are so widely used that I did not find useful results.

Thanks for any pointers.
Steve
Title: Re: Limits to uploaded files by size?
Post by: bmartino1 on July 26, 2015, 01:42:25 PM
i recall a limit for file sizes at one time. To my knowledge, a file would upload the data, but stop at 100 KB(not the full file, file deleted... something like that...) , there would be an error, depending on the file / how it works... PHP is better for this :( ... Sorry, not much help...
Title: Re: Limits to uploaded files by size?
Post by: LeoNeeson on July 27, 2015, 08:27:39 AM
I did this (https://www.google.com/search?q=%22Upload%22+%22Size%22+%22Limit%22+site%3Arejetto.com%2Fforum&hl=en-US) search, and this (https://www.google.com/search?q=%22FHFS%22+%22Upload%22+%22Size%22+%22Limit%22+site%3Arejetto.com%2Fforum&hl=en-US) another search, and I've found that FHFS may be your solution, according to this:

Improve: Uploader.js now specifies the max account size as the max file size also to prevent very large single-file uploads that can exceed the limit (uploader.js)

You may try the latest FHFS version (2.1.2), and find out how "Uploader.js" works. May be raybob (http://www.rejetto.com/forum/profile/?u=9522) can help you better than me. I currently don't have FHFS installed.
Good luck... ;)
Title: Re: Limits to uploaded files by size?
Post by: rejetto on July 27, 2015, 10:41:59 AM
there's no size limit offered, currently.
IIRC http specifies the size of the whole upload procedure, the sum of all the files, that's a bummer.
Anyway you could always check the size of the file at the end of its upload, it's quite late but better than nothing.
I just tried, and found that it is not working for some reason. I'm trying to fix it.
Title: Re: Limits to uploaded files by size?
Post by: bmartino1 on July 27, 2015, 06:14:24 PM
i can recommend using JavaScript to check the file, but not very good at JavaScript / jqurey code...

http://stackoverflow.com/questions/7497404/get-file-size-before-uploading
Title: Re: Limits to uploaded files by size?
Post by: rejetto on July 30, 2015, 11:58:20 AM
ok, i fixed the problem for the next release (coming very soon, 2.3f), and you will be able to check %item-size-kb% in the [upload completed]

So, if you want to set a limit to 1MB, you should check if it's more than 1000.

I added a specific capability to it, and it's to refuse uploads. Any text that you will give will be considered a reason for refusal and the file will automatically be deleted.

This is an example

[upload completed]
{.if|{.%item-size-kb% > 500.}|Sorry, limit of 500KB.}

Title: Re: Limits to uploaded files by size?
Post by: skb on August 09, 2015, 01:07:38 AM
Wow, thanks! That is quite a nice solution! I was thinking I'd need to code some macros; very great to have it as a new built-in! :)
Title: Re: Limits to uploaded files by size?
Post by: skb on August 09, 2015, 01:12:48 AM
Ah, LeoNeeson, very clever using Google to search the forum! I'd never thought of that, and was trying to find stuff using only the local search tool. Thanks for the examples!

Steve
Title: Re: Limits to uploaded files by size?
Post by: LeoNeeson on August 09, 2015, 07:34:58 AM
You're welcome, Steve. And thank you for suggesting this new feature. :)