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 9259243
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T12:36:30+00:00 2026-06-18T12:36:30+00:00

I am creating a script which allows the user to upload images but now

  • 0

I am creating a script which allows the user to upload images but now I want to include a simple if statement which will accept only gif and png . Here is my code but it doesn’t seem to be working the way it has to .

#extention filter
$allowed = array("image/gif","image/png");  
if(!in_array($files,$allowed)){
 $error_message = 'Only jpg, gif, and pdf files are allowed.';
  $error = 'yes';
  echo $error_message;
  exit();
}   #extention
  • 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-18T12:36:32+00:00Added an answer on June 18, 2026 at 12:36 pm
        $filename=$_FILE['name']['filename_in_html'];  //you can change this with your filename
        $allowed='png,jpg';  //which file types are allowed seperated by comma
    
        $extension_allowed=  explode(',', $allowed);
        $file_extension=  pathinfo($filename, PATHINFO_EXTENSION);
        if(array_search($file_extension, $extension_allowed))
        {
            echo "$extension_allowed allowed for uploading file";
        }
        else
        {
            echo "$extension_allowed is not allowed for uploading file";
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm creating a bash script that will run a process in the background, which
I have made this batch script which will allow the user to enter a
I am a creating a MySQL updating script which will allow me to merge
I am currently creating a PHP website which allows administrators to upload a variety
I have a file upload script which will be available to the general public
I am creating a Python script within which I am executing UNIX system commands.
I have a very large script which is creating multiple views. In a number
I have simple table creating script in Postgres 9.1. I need it to create
I am creating a script that I can run and it will simply ask
I'm creating a small ruby script to resize images and save them in a

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.