I’m working with a client who allows users to upload image files to a database through a custom form. Now over time, these will obviously build up. I’m looking for a way to possibly limit the size of the files that they upload.
I’ve had a look through the API documents and reading different articles, but I’m stumped (not a coder by any stretch of the imagination)
Here’s what I’ve got so far, it doesn’t appear to make a difference:
Hello @jonatandor35 , I would like to know about this code in detail. It would be a big help. I have searched many pages but failed to find solution. My conceren is I want my clients to upload image in a restricted manner where file size should be under 2 mb. I saw this post and curious to know above posted code. I have changed some code according to your instruction. Like :
Now second question is if above code is correct, how this code works. Is this code works with a button single handedly or we need additional upload button for it ! I am counfused. Thanks in advance : )
@onlinesanawad Hi, sorry I haven’t been here for a while.
I’ll guess you man 200 mega byte (MB) and not 200 mega bit (Mb).
1 mega byte is 1024 * 1024 bytes so your calculation is not completely accurate.
Use a single upload button for it. The value array contains the files and their sizes.
@jonatandor35 Suppose I have a upload button allowing a single file/image to upload. I want to restrict user to upload under 2 megabyte file size / image size only. If file is having greater mb upload fails and give error caution. Is it possible? Thanks : )