Support

Account

Home Forums Bug Reports Upload validation prevents uppercase filetype Reply To: Upload validation prevents uppercase filetype

  • Hi @crabilld

    Thanks for the bug report.

    I’ve just found and fixed the issue.
    Can you please edit the api/api-helpers.php file on line 3224 and change the if statement to:

    
    // file type
    	if( $file['type'] ) {
    		
    		$mime_types = acf_maybe_get($field, 'mime_types', '');
    		
    		// lower case
    		$file['type'] = strtolower($file['type']);
    		$mime_types = strtolower($mime_types);
    		
    		
    		// explode
    		$mime_types = str_replace(array(' ', '.'), '', $mime_types);
    		$mime_types = explode(',', $mime_types); // split pieces
    		$mime_types = array_filter($mime_types); // remove empty pieces
    		
    		if( !empty($mime_types) && !in_array($file['type'], $mime_types) ) {
    			
    			// glue together last 2 types
    			if( count($mime_types) > 1 ) {
    				
    				$last1 = array_pop($mime_types);
    				$last2 = array_pop($mime_types);
    				
    				$mime_types[] = $last2 . ' ' . __('or', 'acf') . ' ' . $last1;
    				
    			}
    			
    			$errors['mime_types'] = sprintf(__('File type must be %s.', 'acf'), implode(', ', $mime_types) );
    			
    		}
    				
    	}
    

    This should allow uppercase file extensions to validate correctly.

    Thanks
    E