Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7869487
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T01:20:13+00:00 2026-06-03T01:20:13+00:00

In my form there is an input to re-name the file. When they choose

  • 0

In my form there is an input to re-name the file. When they choose a file to upload it is checked to make sure it is only a .pdf file. I am trying to check the input to make sure they did not add a file extension to the new name. I am trying to check for any variation of ‘pdf’ Here is what I have but is there a better way to do this. Any help welcome, Thanks

  <?php
    function get_file_extension($pdf)
    {
     return substr(strrchr($pdf,'.'),0);
    }

    $pdf = "test.pdf";

    $test = strstr($pdf, '.');
    $pdf_ext = array('.pdf','.PDF','.Pdf','.PDf','.pdF','.pDf','.PdF','.PdF');
    $test =  get_file_extension($pdf);
    if($test == in_array($test,$pdf_ext)) {
       echo 'you do not a .pdf';
    } else {
       echo 'name ok';
    }
   ?>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T01:20:15+00:00Added an answer on June 3, 2026 at 1:20 am

    Simply use strtolower or strtoupper:

    if(strtolower($test) == 'pdf') {
       echo 'pdf';
    } else {
       echo 'no pdf';
    }
    

    Or

    if(strtoupper($test) == 'PDF') {
       echo 'pdf';
    } else {
       echo 'no pdf';
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Assuming there are 5 inputs in web form <input name='the_same[]' value='different' /> <input name='the_same[]'
I need help with my form. There's a mix of input, textarea and file
I have an HTML form with an input field to upload a file. I
I'm trying to create a consent form, and having the user input their name.
I have a enrollment form where users have to input there address. I am
I have a HTML form ( upload.htm ) with a HTML file upload control
I have a contact form in my flash file with name/email/message fields which a
I have a file upload form set up with the HTML5 multiple attribute. However,
to start off i am showing the user one file input field and they
I've got three input fields: NAME, AGE, COUNTRY I want to check if NAME

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.