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
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>
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