Welcome Guest, Not a member yet? Register   Sign In
Mp3 Mime-type?
#11

[eluser]TheFuzzy0ne[/eluser]
Hmmm. Is the file in the logs directory at all?
#12

[eluser]pistolPete[/eluser]
file() normally returns an array whose entries contain the line endings, therefore in_array() probably won't ever return true.

Code:
(...)
    if (file_exists($log_file))
    {
        $file = file($log_file, FILE_IGNORE_NEW_LINES);
            
        if (in_array($mime, $file))
        {
            return FALSE;
        }
    }

    $file = fopen($log_file,'a');
    fwrite($file, $mime."\n");
    fclose($file)
    return FALSE;

    }
}

// End of file: MY_Upload.php
// Location: ./system/application/libraries/MY_Upload.php
#13

[eluser]TheFuzzy0ne[/eluser]
It should be:
Code:
if ( ! in_array($mime, $file))

I've corrected it above again.

EDIT: I think I'm forgetting the 8 Ps Tongue
#14

[eluser]markanderson993[/eluser]
Ah ok. I'll try that!
#15

[eluser]markanderson993[/eluser]
Uh oh! An error!

Quote:A PHP Error was encountered

Severity: Notice

Message: Array to string conversion

Filename: libraries/MY_Upload.php

Line Number: 42

this is the code as of now right?

Code:
<?php

class MY_Upload extends CI_Upload {
    
    function is_allowed_filetype()
    {
        if (count($this->allowed_types) == 0 OR ! is_array($this->allowed_types))
        {
            $this->set_error('upload_no_file_types');
            return FALSE;
        }
                
        foreach ($this->allowed_types as $val)
        {
            $mime = $this->mimes_types(strtolower($val));
        
            if (is_array($mime))
            {
                if (in_array($this->file_type, $mime, TRUE))
                {
                    return TRUE;
                }
            }
            else
            {
                if ($mime == $this->file_type)
                {
                    return TRUE;
                }    
            }        
        }
        # START EDIT #
        $log_file = BASEPATH . 'logs/unknown_mimes.log';
        
        if (file_exists($log_file))
        {
            $file = file($log_file);
            
            if ( ! in_array($mime, $file))
            {
                $file[] = $mime;
                $mime = implode("\n", $file);
            }
        }
        
        file_put_contents($log_file, $mime);
        
        # END EDIT #
        return FALSE;
    }
}

// End of file: MY_Upload.php
// Location: ./system/application/libraries/MY_Upload.php
#16

[eluser]TheFuzzy0ne[/eluser]
I thought that mime was the mime type of the current file, not an array of mimes. I've changed the code again. If you get any more errors, I'll just create a controller and test it myself.

EDIT: On second thoughts, I can see that's not going to work either. Gonna go get some food, and then I'll write some code, and test it.

EDIT 2: On third thoughts, try it out, I think I fixed it. If not, then I'll fix and test it.
#17

[eluser]markanderson993[/eluser]
Now I don't get any errors but nothing is being added to the log. :/
#18

[eluser]TheFuzzy0ne[/eluser]
Please see my previous edit (EDIT 2) Big Grin
#19

[eluser]markanderson993[/eluser]
I hate being so harsh on you but your gonna have to get some food then test it. I still tried it with no luck, nothing showed up in the log :/
#20

[eluser]TheFuzzy0ne[/eluser]
OK, the code is now tested and confirmed as working. Some file do not have mime types, so you will see a line saying "No Mime Type!" in the log file if one or more of these files is submitted.




Theme © iAndrew 2016 - Forum software by © MyBB