Support » Fixing WordPress » How to allow .ged file uploads

  • Resolved colinsp


    I am trying to allow gedcom file uploads. These files have a .ged extension.

    Gedcom files do not have a mime type.

    I have tried the following code with various text/types such as csv, rtf etc without success.

        function my_mime_types($mime_types){
    $mime_types['ged'] = 'text/csv';
        return $mime_types;}
    add_filter('upload_mimes', 'my_mime_types', 1, 1);

    Any suggestions as to how to add this type of file extension to the permitted uploads?

    The page I need help with: [log in to see the link]

Viewing 5 replies - 1 through 5 (of 5 total)
  • The 5.0.1 release was a security release partially concerning file uploads and mime types having to match. Read here:
    So, it’s new, and I don’t think anything is written about it besides the dev note linked there.

    Thanks, Looks like I may be stuffed for now then.

    I have fixed this with a change to a type of text/plain and it now works.

    Hi @colinsp, I wanted to understand this area better and spent some time troubleshooting and reading upload-related code. I’m able to upload a .ged file if I add it as the “text/plain” MIME type:

    function gedcom_support_add_mime_type( $mimes ) {
    	$mimes[ 'ged' ] = 'text/plain';
    	return $mimes;
    add_filter( 'upload_mimes', 'gedcom_support_add_mime_type' );

    This appears to be the PHP finfo_file function takes a look at the file and guesses it to be text/plain. Then the detected type is compared with the type we registered for the file extension.

    I don’t know how finfo_file works, but maybe another MIME type would work if the platform is configured to recognize .ged as such.

    I hope this helps!

    I clearly missed your last post. 🙂 I’m glad you already have it working. Cheers!

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘How to allow .ged file uploads’ is closed to new replies.