• I have installed the frontend uploader, but I can not upload STL Files.
    How can I make this possible?

    I already tried to copy the following code, but I get an error.
    Can you please help me?

    Added code:
    add_filter( ‘fu_allowed_mime_types’, ‘my_fu_allowed_mime_types’ );
    function my_fu_allowed_mime_types( $mime_types ) {
    // Array of 3gp mime types
    // From http://filext.com (there might be more)
    $mimes = array( ‘audio/3gpp’, ‘video/3gpp’ );
    // Iterate through all mime types and add this specific mime to allow it
    foreach( $mimes as $mime ) {
    // Preserve the mime_type
    $orig_mime = $mime;
    // Leave only alphanumeric characters (needed for unique array key)
    preg_replace(“/[^0-9a-zA-Z ]/”, “”, $mime );
    // Workaround for unique array keys
    // If you-re going to modify it for your files
    // Don’t forget to change extension in array key
    // E.g. $mime_types[‘pdf|pdf_’ . $mime ] = $orig_mime
    $mime_types[‘3gp|3gp_’ . $mime ] = $orig_mime;
    }
    return $mime_types;
    }

    https://ww.wp.xz.cn/plugins/frontend-uploader/

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Rinat

    (@rinatkhaziev)

    Hey MTimmy,

    You’re not supposed to use that code as is, it’s just an example. 🙂

    Please add this to your functions.php
    add_filter( 'fu_is_debug', '__return_true' );

    Then try to upload stl file and copy-paste the error message you get and I’ll try to help and fix it.

    Hi,

    I’m also trying to upload stl files.

    using “add_filter( ‘fu_is_debug’, ‘__return_true’ );” i get this error :

    There was an error with your submission

    This kind of file is not allowed. Please, try again selecting other file.:
    File name: box.stl
    MIME-TYPE: application/octet-stream

    can you assist please ?

    Thanks,
    Roee Yossef

    Plugin Author Rinat

    (@rinatkhaziev)

    Hey roeeyossef,

    Something like this should work for you:

    add_filter( 'fu_allowed_mime_types', 'my_fu_allowed_mime_types' );
    function my_fu_allowed_mime_types( $mime_types ) {
        $mime_types['stl'] = 'application/octet-stream';
        return $mime_types;
    }

    Thanks for the reply,

    actually, the way to go is :

    add_filter( 'fu_allowed_mime_types', 'my_fu_allowed_mime_types' );
    function my_fu_allowed_mime_types( $mime_types ) {
    
    $mimes = array( 'text/plain', 'application/vnd.ms-pki.stl', 'application/x-stl'. 'application/vnd.sketchup.skp' );
    
    foreach( $mimes as $mime ) {
    $orig_mime = $mime;
    preg_replace("/[^0-9a-zA-Z ]/", "", $mime );
    
    // I have added stl and skp extensions here
    $mime_types['application/vnd.ms-pki.stl|stl|stl_|skp|skp_|obj|obj_' . $mime ] = $orig_mime;
    }
    return $mime_types;
    }
Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘How upload STL Files?’ is closed to new replies.