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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T12:51:32+00:00 2026-06-03T12:51:32+00:00

I have a website up and running which makes use of file uploads. Everything

  • 0

I have a website up and running which makes use of file uploads. Everything is working fine, except for one of the users. They are using IE8 to upload files from their SharePoint server to the website. When I look at the $_FILES variable in PHP the ‘name’ key looks like this:

somefilename[1]

Instead of

somefilename.pdf

The uploads are then blocked, because the extension is not allowed. Has anyone ever dealt/seen this before? It looks like a temporary name, or a hidden file extension.

Edit:

Some of you requested the $_FILES variable:

[Filedata] => Array
    (
        [name] => Algemene%20Voorwaarden%20Corporate%20Services%202011[2]
        [type] => application/octet-stream
        [tmp_name] => /tmp/phps19zye
        [error] => 0
        [size] => 148021
    )

This should be a PDF file. I need the extension, not only for security reasons, the [type] would be better suited for that, but also for presentation and functionality. I need to display the correct icon for a file type, and separate images for processing.

The HTML form is just a basic test form:

<!DOCTYPE html>
<html>
    <head>
        <title></title>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    </head>
    <body>
        <form action="uploadtest3.php" method="post" enctype="multipart/form-data">
            <input type="file" name="file_upload" id="file_upload" />
            <br /><input type="submit" value="Uploaden" />
        </form>
    </body>
</html>

The PHP file is the following:

$targetFolder = '/uploadtests/uploads3';

if (!empty($_FILES)) {
    $tempFile = $_FILES['file_upload']['tmp_name'];
    $targetPath = $_SERVER['DOCUMENT_ROOT'] . $targetFolder;
    $targetFile = $targetPath . $_FILES['file_upload']['name'];

    move_uploaded_file($tempFile,$targetFile);
        echo "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-03T12:51:33+00:00Added an answer on June 3, 2026 at 12:51 pm

    Introduction

    Have seen this issue before but am not sure what caused it. I would not even like to call it an error because some files extension can be intentionally removed or altered for malicious purpose.

    The most important thing is validating file properly and worry less if a file has extension or not

    Reasons :

    • File Extension Can easily be faked and it would be bad if your application relies on file extension only for validation

    • $_FILES ['file_upload']['type'] would return application/octet-stream for all files with not extension so it not not also a option for validation

    • Since its a browser issue then its a Client Related Problem so you don’t have any control. If you are able to manage this you would definitely increase user experience

    Simple Patch

    The solution is very simple. All you need to validate your file with FILEINFO and fix any extension issue to your uploaded file.

    You also need to validated all uploaded file based on their Mime Type … and remove any invalid file.

    Prove of Concept

    $allowedTypes = array (
            "pdf" => "application/pdf" 
    );
    
    $pathFinal = "final";
    $pathTemp = "temp";
    try {
        if (! empty ( $_FILES )) {
            $tempFile = $_FILES ['file_upload'] ['tmp_name'];
            $fileName = $_FILES ['file_upload'] ['name'];
            $destinationTemp = $pathTemp . DIRECTORY_SEPARATOR . $fileName;
            $destinationFinal = $pathFinal . DIRECTORY_SEPARATOR . $fileName;
            /**
             * Move To tempary File
             */
            move_uploaded_file ( $tempFile, $destinationTemp );
    
            $fileMime = mimeInfo ( $destinationTemp );
            $key = array_search ( $fileMime, $allowedTypes );
    
            /**
             * Validate Mime Type
             */
            if (empty ( $key )) {
                unlink ( $destinationTemp );
                throw new Exception ( "File Type not Supported" );
            }
    
            /**
             * Fix Extention Issues
             */
            $ext = pathinfo ( $destinationTemp, PATHINFO_EXTENSION );
    
            if (empty ( $ext )) {
                $destinationFinal .= "." . $key;
            }
    
            /**
             * Transfer File to Original Location
             */
            copy ( $destinationTemp, $destinationFinal );
            unlink ( $destinationTemp );
    
            echo "OK";
        }
    } catch ( Exception $e ) {
        echo "ERROR :", $e->getMessage ();
    }
    

    Function Used

    function mimeInfo($file) {
        return finfo_file ( finfo_open ( FILEINFO_MIME_TYPE ), $file );
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a running website on wordpress which has been hacked, some file were
I have an asp.net website in my production server which running fine now. Now
Suppose I have an ASP.NET website running with its corresponding web.config file, which contains
I have a Joomla 1.0 website running on a shared host which I don't
I have a running website and now i like to use WP for a
I have a server and a website running 100% fine. The thing is, I
I have website that use XMLHttpRequest (jQuery, actually). I also have another site running
I have a website running in Microsoft SharePoint which uses menus and other data
I have Apache Server, in which my website running, but there is some jsp
I have a website running Joomla! (it's not mine, so I don't know how

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.