Jonathan Mori
asked on
FileUploadControl RegularExpressionValidator to only accepts images, dwg, and pdf and exclude ampersands
Hi, I am trying to figure out a way to limit the fileupload control to only accept certain types of files. These include jpg, gif, png, pdf, and dwg. Also To prevent ampersands in the filename.
I am having trouble getting the regular expression correct.
I am having trouble getting the regular expression correct.
<asp:RegularExpressionValidator id="FileUpLoadValidator" runat="server"
ErrorMessage="Please Only Upload PDF, Image, or DWG files."
ValidationExpression="(?:\\\w+)+\.(?:jpg|JPG|gif|GIF|PDF|pdf|DWG|dwg)$/\.(?:jpg|gif|pdf|dwg)$/i"
ControlToValidate="DocUpload">
</asp:RegularExpressionValidator>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Are you trying first to upload the file and when the response is back to the client, another option is available to insert it into the database?
If so, uploads will not be set in a viewstate, it only posts the data to the webserver.
If you want to do this, you could remember the file location path and name and when the second button is fired, you read the file for the information you need, or you have to set 1 button for uploading and saving within 1 event.
You could separate it into 2 methods that is triggered within 1 event.
I'll hope this is clear to you.
If so, uploads will not be set in a viewstate, it only posts the data to the webserver.
If you want to do this, you could remember the file location path and name and when the second button is fired, you read the file for the information you need, or you have to set 1 button for uploading and saving within 1 event.
You could separate it into 2 methods that is triggered within 1 event.
I'll hope this is clear to you.
ASKER
I've requested that this question be closed as follows:
Accepted answer: 200 points for stephanonline's comment #37569154
Assisted answer: 0 points for GravitaZ24's comment #37572504
Assisted answer: 200 points for stephanonline's comment #37572573
for the following reason:
Thank you, Got it going perfectly!
Accepted answer: 200 points for stephanonline's comment #37569154
Assisted answer: 0 points for GravitaZ24's comment #37572504
Assisted answer: 200 points for stephanonline's comment #37572573
for the following reason:
Thank you, Got it going perfectly!
The answer I gave is the correct answer to the question. Why is the comment from the code a part of the solution if I gave a full solution to the question?
ASKER
I apologize, Both comments helped me so I just split the points.
ASKER
Open in new window