Web Connection
16 Mb limit
Gravatar is a globally recognized avatar based on your email address. 16 Mb limit
  Luca
  All
  Apr 25, 2020 @ 11:35pm

Dear Rick,
I use WC 6.5 in file mode
Please is there any way to block a request with an uploaded file larger than 16 Mb, without getting into error on server?
I know there is no way to upload files larger than 16 Mb, but I would like to get a message error to the client.
I tryed many ways, but without to avoid an error on server.
Alternately, is there another way to upload an heavy file on server from mobile device?
Thank you very much for support

Gravatar is a globally recognized avatar based on your email address. re: 16 Mb limit
  Rick Strahl
  Luca
  Apr 26, 2020 @ 02:07pm

Yes you can do that using JavaScript. You can intercept the file upload with onsubmit() or the file upload button's onload() and check the file control for the file selected - it'll have the size in there.

Something like this:

    <input type="file" name="upload" id="upload" onchange="upload_change(this)" /> 
...
    <script>
        function upload_change(el) {
            for (var i = 0; i < el.files.length; i++) {
                if (el.files[i].size > 1000000) {
                    alert('file ' +  el.files[i].name + ' is too large')                    
                    el.value = "";  // clears list
                    return false;
                }                        
            }
            return true;                    
        }
    </script>

Gravatar is a globally recognized avatar based on your email address. re: 16 Mb limit
  Luca
  Rick Strahl
  Apr 26, 2020 @ 10:42pm

Fantastic!
If Javascript had FoxPro functions like FileToStr() and SubStr(), could I split the file content into several 15 Mb HiddenFields on page?
Many thanks again

Gravatar is a globally recognized avatar based on your email address. re: 16 Mb limit
  Tore Bleken
  Luca
  Apr 27, 2020 @ 10:50pm

For a new question, you should always start a new thread.

© 1996-2024