Filtering the Asp:FileUpload control


J

JeffDotNet

My users need to upload a specific type of file and I would like to assist
them in finding the appropriate file. I don’t believe there is an out of the
box way to filter the files that will be listed in the browsers file browser
dialog. I did however notice that if a user types a filter in the textbox
associated with the fileUpload control (ex: ‘*weeklyStatusReport*.xml’) and
then clicks browse, that this is able to filter the displayed files. This
may only work in internet explorer but for my intranet application this could
be useful. The problem I run into is that I would like to fill in the
textbox associated with the fileUpload control for the user and this is
proving more difficult than I had expected.

I have read access to the file in the textbox with javascript:


var uploader= document.getElementById('<%=Me.FileUpload1.ClientID%>');
if (uploader.value =='')
{args.IsValid=false;

uploader.value=’someText’
Doesn’t produce an error but it doesn’t work either.
I know that there is some protection here to keep asp from uploading files
the users doesn’t want to upload; But hear I am not trying to upload the file
for the user. I am just trying to construct a dynamic file filter to reduce
the number of possible files to be considered. Is there anyway to accomplish
this? If not are there any public domain file uploading controls that are
worth recommending?

Thanks in advance
 
Ad

Advertisements

J

Jeffrey Tan[MSFT]

Hi Jeff,

Thanks for your post!

This is by the design. Setting this <input type=file> html element
programmatically is considered a security risk and is not supported. For
more information, please refer to the link below:
"PRB: Cannot Use Script to Manipulate INPUT TYPE=File Value"
http://support.microsoft.com/kb/266087/en-us

Hope this helps!

Best regards,
Jeffrey Tan
Microsoft Online Community Support
==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
 

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

Top