0

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?

2 Answers 2

0

you need to allow them to be uploaded in your media files.

you can add following code to your themes functions.php and it should work.

function my_mime_types($mime_types){
    $mime_types['ged'] = 'application/octet-stream';
    return $mime_types;
}
add_filter('upload_mimes', 'my_mime_types', 1, 1);

there is more information about adding new mime types in WP here: https://wpsmackdown.com/add-remove-filetypes-wordpress-media-library/#add-filetypes

Here is an info about the .ged File MIME Type: https://whatis.techtarget.com/fileformat/GED-Genealogical-data-GEDCOM

And here a list of the mime_types: https://feedforall.com/mime-types.htm

3
  • Thanks but unfortunately that doesn't work, Wordpress still says not an allowed file type. Thanks also for the links I was aware of those as I researched before asking the question.
    – Colin
    Dec 20, 2018 at 12:17
  • hmm.. then i'm sorry. i think it might be still the wrong MIME type. just read something here gedcomx.org/2013/06/19/gedcomx-media-types.html with application/x-gedcomx-v1+xml or application/x-gedcomx-v1+json Dec 20, 2018 at 12:22
  • Thanks but gedcomx is a totally different format being XML. Gedcom is just standard txt.
    – Colin
    Dec 20, 2018 at 13:05
0

I have now resolved this by changing the type to text/plain so the code now looks like:

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

It seems that a security patch in v5.0.1 and v4.9.9 has tightened up the mime type of uploads and the checking of the file types.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.