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

  • Home
  • SEARCH
  • 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 6360073
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T23:36:07+00:00 2026-05-24T23:36:07+00:00

I am building a php application. I can easily upload an image or any

  • 0

I am building a php application.
I can easily upload an image or any other type of data, but not a .jar. Below my code:

Upload.php

<form action="getfile.php" method="post" name="uploadForm" id="uploadForm" enctype="multipart/form-data"  ><br>
    <?php echo gettext("Image "); ?> 
        <input name="imagen" value="" type="file" id="imagen" />

    <?php echo gettext("Jar "); ?> 
        <input name="jarFile" value="" type="file" id="jarFile" />
</form>

getfile.php

$fileName = $_FILES['jar']['name'];
$fileType = $_FILES['jar']['type'];
//Check the extension
if (!strpos($fileType, "jar") ) {
    echo gettext("The simulation must be jar extension. Try again.");
}else{

    if (move_uploaded_file($_FILES['jar']['tmp_name'], $path)){
       echo gettext("Simulation stored succesfully.");
    }else{
       echo gettext("Something happened. Try again. ");
    }
}

For images I am following the same aproach, but when I try to upload a jar file, I am always getting the error

The simulation must be jar extension. Try again

and $fileType is empty. Is there some restriction at this point? Am I missing something??

Thanks in advance

  • 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-24T23:36:07+00:00Added an answer on May 24, 2026 at 11:36 pm

    The type property is unreliable (and populated by the browser). Your best bet is to retrieve the MIME file type:

    $fhandle = finfo_open(FILEINFO_MIME);
    $mime_type = finfo_file($fhandle, $_FILES['jar']['tmp_name']);
    

    The $mime_type should be application/java-archive.

    PHP >= 5.3.0

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

Sidebar

Related Questions

I'm currently building a simple web application in PHP that other company's can use
I am currently building an MVC application in PHP (not using any frameworks). I
I'm building a PHP application using the data mapper pattern to separate my DB
I'm building a PHP Web Application for Company A in which users can login
I am building a php application that work on weather data and agricultural data.
I am building php web application that let's a user upload a MS Access
I building my first cake PHP application, all things configured correctly, but when i
I am building a PHP application in CodeIgniter. CodeIgniter sends all requests to the
I am building an application currently in PHP and I am trying to decide
I am building a web application that is currently PHP with MySQL. There is

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.