Forums Register Login
uploading a file but want to restrict the type of files
I am using jsp for file uploading in my struts application,

i am able to upload a file but want to limit the type of files that can be uploaded. how can we restrict user to upload file with specified extension....the file should not be inserted in the daatabase if its of other type
You can't restrict what gets uploaded, so you need to perform any required checks on the server before working with the data. Note that the file extension is not necessarily indicative of the file content, so you should perform a semantic check of that as well.
okk...cant we use javascript which ll check the extension and if its different other than d specification,it will give alertbox...?
Client-side JavaScript has no concept of files.
And Javascript doesn't have access to input fields of "file" type for security reasons.
(1 like)
Might people fall in love with java script, In struts 2 We have FileUploadInterceptor there you can specify the allowed file ContentType, maximum file size that can be uploaded and you can define allowed file extension types.
Is ther any facility in struts 1...?? in my application,i want user to upload only pdf files...
and only those files should b inserted in database...if he tries to upload other files such as bmp,jpg...these files should not be inserted..
so how can i achieve this....??
Wink, wink, nudge, nudge, say no more ... https://richsoil.com/cards

This thread has been viewed 1504 times.

All times above are in ranch (not your local) time.
The current ranch time is
Feb 25, 2018 11:03:48.