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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T07:20:32+00:00 2026-05-29T07:20:32+00:00

I have an application here I have 2 questions: Question 1: How do I

  • 0

I have an application here

I have 2 questions:

Question 1: How do I fix the notice?

Below is the code:

<?php

If(isset($_POST)) 
{ 

$allowedImageTypes = array("image/pjpeg","image/jpeg","image/jpg","image/png","image/x-png","image/gif");
$file = $_FILES['imageFile'];  // this is the line the notice is pointing to
$fileType = $file['type'];
if (!in_array($fileType, $allowedImageTypes)) { 
    echo "Unsupported file type";
}
else
{
    // Process the file
}
}
?>

Question 2: If you open the application, click on the “Add Question” button. This will add a table row. Now in the file input select a file which is invalid (like a .txt file for example).Now click on the “submit Details” button, it will state in an alert an “Unsupported file type” for question 1. Now go back to file input and change file to a valid format (.png, .jpg, .jpeg or .gif) and then after you have done that click on the “submit Details” button again, this time a confirmation box appears stating a message and if you want to proceed.

Now this all works fine on client side but what I want is that when the user clicks on the “Submit Details” button, I want it to check if the file format is correct in server side as well as client side for security purposes. If it is valid then don’t show message and if invalid then show message on top “Unsupported File Type”. If a file input is blank then it is valid but if one file input contains the wrong file format, then display the invalid message. Does anyone know how to do this? Is the php code nearly there from achieving this?

You can view full code in view source if you wish

  • 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-05-29T07:20:33+00:00Added an answer on May 29, 2026 at 7:20 am

    change if(isset($_POST)) to if(count($_POST) > 0)
    or even better if you check if(isset($_FILES[“imageFile”]))

    Working on question 2

    it is not possible in traditional HTML to check that at client side. you may look at solutions like plupload or swfupload with jquery connectors which are flash and HTML5 oriented uploading solutions

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a question here regarding iPhone app submission. I have a free application
here is a good question: I have an application compiled for iPhone OS 2.21.
Here's my first question at SO. I have a internal application for my company
Here's my question. Right now I have a Linux server application (written using C++
I have an application I need to analyze. I have the source code here.
I want to fix warnings in my application code. I have an AddressBookModel.h which
I have windows forms application wich runs another console application here is the part
Here is my situation: I have an application that use a configuration file. The
Here is the scenerio: We have an application running on Webphere Portal Server 6.1
Kinda stuck here... I have an application with lets say 5000 rows of data

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.