Uploaded image for project: 'phpBB3'
  1. phpBB3
  2. PHPBB3-11148

Fix uploading attachments from Android 4 powered devices


    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 3.0.11
    • Fix Version/s: 3.1.0-RC3
    • Component/s: Posting
    • Labels:


      Trying to upload an attachment to phpBB from some mobile devices running Android 4.x results in the following error:

      The image file you tried to attach is invalid.

      This is caused by an invalid mimetype, returned by the default Android browser. The incorrect mimetype is: application/octet-stream
      phpBB looks if it contains image/ and is therefore failing the check and rejecting the attachment.

      I've come to this conclusion by upload tests from people on different mobile devices, operating systems and browsers:

      [OK]   HTC Desire Android 2.3.5
      [OK]   HTC Sensation Android 2.3.4
      [FAIL] HTC Sensation Android 4.0.3
      [FAIL] HTC One S Android 4
      [OK]   HTC One S Android 4 (Firefox)
      [FAIL] HTC HD2 Android 4.1.2
      [FAIL] HTC EVO 4G LTE Android 4.0.4 
      [FAIL] Nexus S Android 4
      [OK]   Samsung Galaxy S2 Android 4.0.4 
      [OK]   Samsung Galaxy S2 Android 4.0.4 (Opera Mobile)
      [OK]   Samsung Galaxy S3 Android 4.0.4
      [OK]   Samsung Galaxy S3 Android 4.0.4 (Firefox) 
      [OK]   iPhone 4 iOS 6.0
      [OK]   iPad 2 iOS 6.0 (10A403)
      [OK]   Samsung Focus (SGH-i917) Windows Phone 7.5 

      (Thanks for testing everyone)

      Please note that disabling the ACP setting "Check attachment files, Some browsers can be tricked to assume an incorrect mimetype for uploaded files.." will not help because it's checked in includes/functions_posting.php, regardless of the setting. (the setting is only working in includes/functions_upload.php which is runned after functions_posting)


      // Make sure the image category only holds valid images...
      if ($cat_id == ATTACHMENT_CATEGORY_IMAGE && !$file->is_image())
      	// If this error occurs a user tried to exploit an IE Bug by renaming extensions
      	// Since the image category is displaying content inline we need to catch this.


      * Check if file is an image (mimetype)
      * @return true if it is an image, false if not
      function is_image()
      	return (strpos($this->mimetype, 'image/') !== false) ? true : false;


          Issue Links



              • Assignee:
                Marc Marc
                Derky Derky
              • Votes:
                0 Vote for this issue
                2 Start watching this issue


                • Created: