-2

Suppose client wants to upload image file or any other attachment . And maximum size can be 10 Mb , So where file size check should be placed front-end or server back-end side? which is better design and why ?

user18424
  • 401
  • 1
  • 3
  • 8

2 Answers2

4

It should be at both ends.

Why at client side(front end).

It will be annoying for user if you throw an error after 10mb data is uploaded and this 10mb data will be also uploaded at server side so you will be wasting servers processing power.

Why at server side(back end)

Some people can hack client side code and upload files more than 10mb so you should have validation at server side also

suraj.tripathi
  • 417
  • 2
  • 15
1

If the client is browser based, then you must have server side validation because it is easy and widely known how to circumvent a client side validation. You may have a client side validation as well for the normal users.

If the flient is a proper application and it is the only channel to your server, then have a client side valudation becsuse it is closer to your users. If there are multiple channels to the server, then you may want to add the server side validation to enforce consistency accross all channels.

Shadow
  • 33,525
  • 10
  • 51
  • 64