wp filesystem - How to upload .tex files in wordpress?

admin2025-06-03  2

I am trying to upload tex files in my wordpress site. The methods I have tried and failed or the following. First of all the error I got is,

Sorry, this file type is not permitted for security reasons.

Tried Methods:

  • Method 1:

Added the below line in wp-config.php

define('ALLOW_UNFILTERED_UPLOADS', true);

Which did not work.

  • Method 2

Added the following codes which allows mime types in functions.php

// Adding Mime types 
function my_myme_types( $mime_types ) {
  $mime_types['svg'] = 'image/svg+xml';     // Adding .svg extension
  $mime_types['json'] = 'application/json'; // Adding .json extension
  $mime_types['tex'] = 'application/octet-stream'; // Adding .tex extension   
  return $mime_types;
}
add_filter( 'upload_mimes', 'my_myme_types');

which again did not help. I remember that only once the file got uploaded in local copy of the website which I dont know how?

  • Method 3

Added the plugin WP Add Mime Types, thinking that I can try adding the mime type. But It already shows me that 'appliations/x-tex' is already added from the method 2.

None of the above method helped me to upload the .tex files. Note that pdf files are getting uploaded without any issue.

PS: I am using a form to upload files. You may check here . Any suggestions would be really helpful.

I am trying to upload tex files in my wordpress site. The methods I have tried and failed or the following. First of all the error I got is,

Sorry, this file type is not permitted for security reasons.

Tried Methods:

  • Method 1:

Added the below line in wp-config.php

define('ALLOW_UNFILTERED_UPLOADS', true);

Which did not work.

  • Method 2

Added the following codes which allows mime types in functions.php

// Adding Mime types 
function my_myme_types( $mime_types ) {
  $mime_types['svg'] = 'image/svg+xml';     // Adding .svg extension
  $mime_types['json'] = 'application/json'; // Adding .json extension
  $mime_types['tex'] = 'application/octet-stream'; // Adding .tex extension   
  return $mime_types;
}
add_filter( 'upload_mimes', 'my_myme_types');

which again did not help. I remember that only once the file got uploaded in local copy of the website which I dont know how?

  • Method 3

Added the plugin WP Add Mime Types, thinking that I can try adding the mime type. But It already shows me that 'appliations/x-tex' is already added from the method 2.

None of the above method helped me to upload the .tex files. Note that pdf files are getting uploaded without any issue.

PS: I am using a form to upload files. You may check here . Any suggestions would be really helpful.

Share Improve this question asked Jan 31, 2019 at 6:55 gloomgloom 1851 gold badge3 silver badges12 bronze badges 1
  • Hopefully this can help – birgire Commented Jan 31, 2019 at 7:17
Add a comment  | 

1 Answer 1

Reset to default 0

Mime Type are not correct.

application/x-tex

Complete detail MimeType Source : https://www.lifewire/mime-types-by-content-type-3469108

转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1748958689a315161.html

最新回复(0)