HTML + <input type=file> constraint doesnt work

B

Bhavin

Hi
I'm trying to input image file using this synax.
<input type=file name="tx_file" accept="image/*"
class=boxText>
But when open file dialouge appears, it shows all the
file and user can select any file and i.e. i dont want.
Can any one suggest me?
Cheers,
Bhavin
 
A

Aaron Bertrand [MVP]

Hi
I'm trying to input image file using this synax.
<input type=file name="tx_file" accept="image/*"
class=boxText>
But when open file dialouge appears, it shows all the
file and user can select any file and i.e. i dont want.
Can any one suggest me?

Yes, use client-side JavaScript to make sure the value of the field has the
proper extension before they can submit.
 
T

Tim Slattery

Bhavin said:
Hi
I'm trying to input image file using this synax.
<input type=file name="tx_file" accept="image/*"
class=boxText>
But when open file dialouge appears, it shows all the
file and user can select any file and i.e. i dont want.
Can any one suggest me?

The "name" attribute of the <input type="file"...> is read-only. If
you could assign a value to it, then you could upload *any* file from
*any* client's computer without the user being aware of what was going
on.

You can check the value the user has given the attribute when the form
is submitted (or each time the value is changed, though that kind of
thing can get messy).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top