Jump to content

Recommended Posts

You could use the following code to determine they have a valid filename:

 

if (!preg_match('/[\d]{15}\.ask/', $_FILES['input_name']['name']))
{
    // invalid
}
else
{
    // valid
}

 

Not tested but should work no problems. I'm assuming you know how to do the rest?

\d does not need to be wrapped in brackets because it is itself a shorthand character class.  But you don't really want to use it anyways, as \d accepts more than strictly 0-9.  Better to explicitly use 0-9.  Also your original regex probably wasn't working due to you not anchoring boundaries to it.  You kind of fixed it by adding word boundary shorthands to it but that just stops someone from entering in "blah232343..." not "blah 234324..." or "blah@234324..." etc... also you put the 2nd one in the wrong place.  The anchors you really want are the start and end of line anchors ^...$

 

/^[0-9]{15}\.ask$/

 

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.