Skip to Main Content

APEX

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How to limit filesize when upload an image?

Faisal Ahmed JoneyMay 5 2016 — edited May 13 2016

I have a picture item in my application. I want to restrict the image filesize and show an alert like "your filesize can be maximum 2MB" .

I tried it with the java-script below it show only the alert but don't restrict the size.

var oFile = document.getElementById("P231_PIC").files[0]; // <input type="file" id="P231_PIC" accept=".jpg,.png,.gif,.jpeg"/>

if (oFile.size > 2097152) // 2 mb for bytes.

{

alert("File size must under 2mb!");

return;

}

it should be like below when I choose more then 2mb.

2016-05-05_234207.jpg

I will be very grateful if anyone help.

This post has been answered by PMON on May 5 2016
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 10 2016
Added on May 5 2016
6 comments
1,375 views