$conf, $runtime; function_exists('chdir') AND chdir(APP_PATH); $r = 'mysql' == $conf['cache']['type'] ? website_set('runtime', $runtime) : cache_set('runtime', $runtime); } function runtime_truncate() { global $conf; 'mysql' == $conf['cache']['type'] ? website_set('runtime', '') : cache_delete('runtime'); } register_shutdown_function('runtime_save'); ?>How to allow .ged file uploads|Programmer puzzle solving
最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

How to allow .ged file uploads

matteradmin9PV0评论

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?

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?

Share Improve this question asked Dec 20, 2018 at 12:00 ColinColin 1356 bronze badges
Add a comment  | 

2 Answers 2

Reset to default 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/add-remove-filetypes-wordpress-media-library/#add-filetypes

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

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

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.

Articles related to this article

Post a comment

comment list (0)

  1. No comments so far