Hi!
My doubt is quite simple, but unfortunately I was not able to solve it and didn't find the answer anywhere.
I've a page that allows the user to send a upload, I would like to BLOCK the upload only if the file has the .exe extension.
Every regex that I've thought about didn't work well, like:
^(?!.*\.exe$).*$
.*\.(exe)$
\.exe$
Thank you!
fileUpload block .exe upload
-
- Posts: 13
- Joined: 17 Dec 2012, 15:13
PrimeFaces: 5.0
JSF: Mojarra/2.2.6
Server: Wildfly 8.1.0.final
JSF: Mojarra/2.2.6
Server: Wildfly 8.1.0.final
- ademkursatuzun
- Posts: 21
- Joined: 08 Apr 2013, 13:22
Post your code.Maybe you're missing something.You are using "allowTypes" for fileUploader aren't you ?
PrimeFaces 5.2 !|! Glassfish 4.0 !|! Mojarra 2.2.0 /
Mac Os X !|! Firefox 32.0
_______________________________________/
root@server:~f LLLSDLaserControl -ck 1 ]
Mac Os X !|! Firefox 32.0
_______________________________________/
root@server:~f LLLSDLaserControl -ck 1 ]
-
- Posts: 13
- Joined: 17 Dec 2012, 15:13
Hi ademkursatuzun!ademkursatuzun wrote:Post your code.Maybe you're missing something.You are using "allowTypes" for fileUploader aren't you ?
Yes, I'm using allowTypes:
Code: Select all
<p:fileUpload allowTypes="/^(?!.*\.exe$).*$/" fileUploadListener="#{feedbackController.handleFileUpload}" fileLimit="1" style="width:100%" sizeLimit="8388608" />
I've tried all above options, with and without the regex between the slashes "/REGEX/":
^(?!.*\.exe$).*$
.*\.(exe)$
\.exe$
PrimeFaces: 5.0
JSF: Mojarra/2.2.6
Server: Wildfly 8.1.0.final
JSF: Mojarra/2.2.6
Server: Wildfly 8.1.0.final
- andyba
- Expert Member
- Posts: 2473
- Joined: 31 Mar 2011, 16:27
- Location: Steinfeld, near Bremen/Osnabrück, DE
- Contact:
Things like allowedTypes work in any upload mode other than simple. In the case of simple you have to reject the uploaded file on the server side.
PF 4.x (Elite versions), PF 5, Pf 5.1, PF 6.0
Glassfish 4.1, Mojarra 2.x, Java 8, Payara 4.1.1.
If you haven't read the forum rules read them now
Glassfish 4.1, Mojarra 2.x, Java 8, Payara 4.1.1.
If you haven't read the forum rules read them now
-
- Posts: 13
- Joined: 17 Dec 2012, 15:13
andyba wrote:Things like allowedTypes work in any upload mode other than simple. In the case of simple you have to reject the uploaded file on the server side.
Thank's andyba, but how can I block the upload of .exe files using other mode rather than simple?
None of my regex is working, and when use something like
Code: Select all
allowTypes="/.*\.(exe)$/"
Code: Select all
<p:fileUpload allowTypes="/.*\.(exe)$/" fileUploadListener="#{feedbackController.handleFileUpload}" fileLimit="1" style="width:100%" sizeLimit="8388608" mode="advanced" />
PrimeFaces: 5.0
JSF: Mojarra/2.2.6
Server: Wildfly 8.1.0.final
JSF: Mojarra/2.2.6
Server: Wildfly 8.1.0.final
- andyba
- Expert Member
- Posts: 2473
- Joined: 31 Mar 2011, 16:27
- Location: Steinfeld, near Bremen/Osnabrück, DE
- Contact:
Find a site that provides JavaScript regular expression testing and get your regex right.
PF 4.x (Elite versions), PF 5, Pf 5.1, PF 6.0
Glassfish 4.1, Mojarra 2.x, Java 8, Payara 4.1.1.
If you haven't read the forum rules read them now
Glassfish 4.1, Mojarra 2.x, Java 8, Payara 4.1.1.
If you haven't read the forum rules read them now
-
- Information
-
Who is online
Users browsing this forum: No registered users and 25 guests