By default it can select all type of files,how to restrict it so that it can only select .pdf
files?
Simply put: you can't using the plain html and javascript. The closest you can get is to test the file extension using javascript before submitting the form and show some error message to the user if it is other than .pdf
. You might need to use some client side solution such as Flash upload controls if you want to achieve this.
You can use the accept attribute on your form to suggest to the browser to restrict certain types. However, you'll want to re-validate in your server-side code to make sure. Never trust what the client sends you.
more explicitly...
<input type="file" accept="application/pdf" />