rejetto forum

Limits to uploaded files by size?

skb · 9 · 10342

0 Members and 1 Guest are viewing this topic.

Offline skb

  • Occasional poster
  • *
    • Posts: 50
    • View Profile
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
« Last Edit: July 26, 2015, 01:18:08 AM by skb »


Offline bmartino1

  • Tireless poster
  • ****
    • Posts: 911
  • I'm only trying to help i mean no offense.
    • View Profile
    • My HFS Google Drive Shared Link
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...
Files I have snagged and share can be found on my google drive:

https://drive.google.com/drive/folders/1qb4INX2pzsjmMT06YEIQk9Nv5jMu33tC?usp=sharing


Offline LeoNeeson

  • Tireless poster
  • ****
    • Posts: 859
  • Status: On hiatus       (sporadically here)
    • View Profile
    • twitter.com/LeoNeeson
I did this search, and this 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 can help you better than me. I currently don't have FHFS installed.
Good luck... ;)
HFS in Spanish (HFS en Español) / How to compile HFS (Tutorial)
» Currently taking a break, until HFS v2.4 get his stable version.


Offline rejetto

  • Administrator
  • Tireless poster
  • *****
    • Posts: 13523
    • View Profile
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.


Offline bmartino1

  • Tireless poster
  • ****
    • Posts: 911
  • I'm only trying to help i mean no offense.
    • View Profile
    • My HFS Google Drive Shared Link
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
Files I have snagged and share can be found on my google drive:

https://drive.google.com/drive/folders/1qb4INX2pzsjmMT06YEIQk9Nv5jMu33tC?usp=sharing


Offline rejetto

  • Administrator
  • Tireless poster
  • *****
    • Posts: 13523
    • View Profile
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.}



Offline skb

  • Occasional poster
  • *
    • Posts: 50
    • View Profile
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! :)


Offline skb

  • Occasional poster
  • *
    • Posts: 50
    • View Profile
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


Offline LeoNeeson

  • Tireless poster
  • ****
    • Posts: 859
  • Status: On hiatus       (sporadically here)
    • View Profile
    • twitter.com/LeoNeeson
You're welcome, Steve. And thank you for suggesting this new feature. :)
HFS in Spanish (HFS en Español) / How to compile HFS (Tutorial)
» Currently taking a break, until HFS v2.4 get his stable version.