OJS OCS OMP OHS

You are viewing the PKP Support Forum | PKP Home Wiki



Problems Uploading

Are you responsible for making OJS work -- installing, upgrading, migrating or troubleshooting? Do you think you've found a bug? Post in this forum.

Moderators: jmacgreg, btbell, michael, bdgregg, barbarah, asmecher

Forum rules
What to do if you have a technical problem with OJS:

1. Search the forum. You can do this from the Advanced Search Page or from our Google Custom Search, which will search the entire PKP site. If you are encountering an error, we especially recommend searching the forum for said error.

2. Check the FAQ to see if your question or error has already been resolved.

3. Post a question, but please, only after trying the above two solutions. If it's a workflow or usability question you should probably post to the OJS Editorial Support and Discussion subforum; if you have a development question, try the OJS Development subforum.

Postby asmecher » Tue Feb 27, 2007 10:41 am

Hi Stewie,

Google is your friend: see http://www.google.ca/search?q=%22failed+to+load+magic+database. You need to configure the location of the type database.

Regards,
Alec Smecher
Open Journal Systems Team
asmecher
 
Posts: 8905
Joined: Wed Aug 10, 2005 12:56 pm

Postby Stewie » Tue Feb 27, 2007 1:39 pm

Alec,

I had come across that post. when I go into c\php\extras
There is no magic.mime file

I did some searching and I found php_magic_mime.dll, is that the same thing?

At anyrate I put that in the c\php\ext along with the other dll's and I uncommented
extension=php_mime_magic.dll

I know that this is not right as it is not working still. but I could not find a magic.mime file anywhere to download.

Also I am not sure what file to change to point to the magic.mime, would it be the string.inc.php file?

Thanks again
Stewie
 
Posts: 23
Joined: Fri Feb 23, 2007 8:44 am

Postby asmecher » Tue Feb 27, 2007 2:01 pm

Hi Stewie,

According to a comment at http://www.php.net/manual/en/function.finfo-open.php, there is a magic.mime file available at http://link.toolbot.com/sourceforge.net/15074.

Regards,
Alec Smecher
Open Journal Systems Team
---
Don't miss the First International PKP Scholarly Publishing Conference
July 11 - 13, 2007, Vancouver, BC, Canada
http://ocs.sfu.ca/pkp2007/
asmecher
 
Posts: 8905
Joined: Wed Aug 10, 2005 12:56 pm

Postby Stewie » Tue Feb 27, 2007 2:37 pm

Alec,

I downloaded that file and put it in c:\php\extras

in the sting.inc.php I added the following line to the code you gave me
\PHP\extras\file-4.18-bin\share\file\magic

so that section looks like:
Code: Select all
        function mime_content_type($filename) {
                if (function_exists('mime_content_type')) {
                        return mime_content_type($filename);
                } elseif (function_exists('finfo_open \PHP\extras\file-4.18-bin\share\file\magic')) {
                        static $fi;
                        if (!isset($fi)) {
                                $fi = finfo_open();
                        }
                        if ($fi !== false) {
                                return finfo_file($fi, $filename);
                        }
                }

                // Fall back on an external "file" tool
                $f = escapeshellarg($filename);
                $result = trim(`file -bi $f`);
                // Make sure we just return the mime type.
                if (($i = strpos($result, ';')) !== false) {
                        $result = trim(substr($result, 0, $i));
                }
                return $result;
        }


doing this got rid of the:
Warning: finfo_open() [function.finfo-open]: Failed to load magic database at '(null)'. in C:\Inetpub\wwwroot\ojs\classes\core\String.inc.php on line 212
error, but the other 2 are still there:
Warning: shell_exec() [function.shell-exec]: Unable to execute 'file -bi "c:\ojsfiles\php9.tmp"' in C:\Inetpub\wwwroot\ojs\classes\core\String.inc.php on line 221

Warning: Cannot modify header information - headers already sent by (output started at C:\Inetpub\wwwroot\ojs\classes\core\String.inc.php:221) in C:\Inetpub\wwwroot\ojs\classes\template\TemplateManager.inc.php on line 187

any ideas?

Thanks
Stewie
 
Posts: 23
Joined: Fri Feb 23, 2007 8:44 am

Postby asmecher » Tue Feb 27, 2007 3:02 pm

Hi Stewie,

Your modification is incorrect -- you can't specify the filename of the magic file there. If you need to specify it in the code, try replacing the line:
Code: Select all
$fi = finfo_open();
...with...
Code: Select all
$fi = finfo_open(FILEINFO_MIME, '/path/to/magic');
...if you've saved the magic file as "/path/to/magic.mime".

Regards,
Alec Smecher
Open Journal Systems Team
---
Don't miss the First International PKP Scholarly Publishing Conference
July 11 - 13, 2007, Vancouver, BC, Canada
http://ocs.sfu.ca/pkp2007/
asmecher
 
Posts: 8905
Joined: Wed Aug 10, 2005 12:56 pm

Postby Stewie » Tue Feb 27, 2007 3:15 pm

Now I get the error:
Parse error: syntax error, unexpected ';' in C:\Inetpub\wwwroot\ojs\classes\core\String.inc.php on line 223

and nothing else loads just that error

You will have to excuse me, I know nothing about php, or really coding for that matter.

Here is that section of code

Code: Select all
        function mime_content_type($filename) {
                if (function_exists('mime_content_type')) {
                        return mime_content_type($filename);
                } elseif (function_exists('finfo_open')) {
                        static $fi;
                        if (!isset($fi)) {
                                $fi = finfo_open(FILEINFO_MIME, '/php/extras/file-4.18-bin/share/file/magic');
                        }
                        if ($fi !== false) {
                                return finfo_file($fi, $filename);
                        }
                }

                // Fall back on an external "file" tool
                $f = escapeshellarg($filename);
                $result = trim(`file -bi $f`);
                // Make sure we just return the mime type.
                if (($i = strpos($result, ';')) !== false) {
                        $result = trim(substr($result, 0, $i));
                }
                return $result;
        }


the magic file is located in c:\php\extras\file-4.18-bin\share\file\magic

The file that I downloaded from the link gave me had a few other folders in the file-4.18 folder, like bin, contrib, include, lib, man, manifest, and share....share is where magic.mime is.
Stewie
 
Posts: 23
Joined: Fri Feb 23, 2007 8:44 am

Postby asmecher » Tue Feb 27, 2007 3:32 pm

Hi Stewie,

You're missing the closing ' in the modified line. (Note: I've corrected the above code listing in case someone else wants to use it.)

Regards,
Alec Smecher
Open Journal Systems Team
---
Don't miss the First International PKP Scholarly Publishing Conference
July 11 - 13, 2007, Vancouver, BC, Canada
http://ocs.sfu.ca/pkp2007/
Last edited by asmecher on Fri Mar 16, 2007 8:29 am, edited 1 time in total.
asmecher
 
Posts: 8905
Joined: Wed Aug 10, 2005 12:56 pm

Postby Stewie » Tue Feb 27, 2007 3:40 pm

Alec,

I was just about to post a reply saying I saw that. When I put that closing ' in it worked fine. No errors :)

Thanks for you help :D
Stewie
 
Posts: 23
Joined: Fri Feb 23, 2007 8:44 am

Warning: finfo_open() [function.finfo-open]: Failed to load

Postby nomadcanuck » Sat Mar 03, 2007 8:33 pm

Using Apache/2.2.4 (Win32) PHP/5.2.1.

Here is how I resolved this error without extra coding.

Warning: finfo_open() [function.finfo-open]: Failed to load magic database at '(null)'.


Code: Select all
$finfo = finfo_open(FILEINFO_MIME, 'C:/wamp/php/extras/magic');


Where file "magic.mime" exists in "C:/wamp/php/extras/".

C:/wamp/php/extras/ is the directory path to magic.mime. magic must be appended to the directory path in the second argument string for finfo_open. Providing full path/magic.mime does not work nor does removing ".mime" from the filename.
nomadcanuck
 
Posts: 1
Joined: Sat Mar 03, 2007 8:21 pm

Postby sean » Mon Apr 02, 2007 11:59 am

I'm having a similar problem. We're running PHP/5.1.6 on CentOS 4. The above solutions do not work for us as we're still getting the "Invalid file format" errors. mime_content_type is not installed, but fileinfo is, yet we're still having the problems. Any suggestions?
sean
 
Posts: 37
Joined: Thu Mar 15, 2007 3:25 pm

Postby asmecher » Mon Apr 02, 2007 12:11 pm

Hi Sean,

The best way to debug this is probably to temporarily insert a few "echo" statements into the mime_content_type function in classes/core/String.inc.php. Make sure that the finfo_open function is being properly detected, and that the fileinfo data is being successfully loaded. Are you sure that you've specified a location to a valid mime database that is readable by the web server user?

Regards,
Alec Smecher
Open Journal Systems Team
---
Don't miss the First International PKP Scholarly Publishing Conference
July 11 - 13, 2007, Vancouver, BC, Canada
http://ocs.sfu.ca/pkp2007/
asmecher
 
Posts: 8905
Joined: Wed Aug 10, 2005 12:56 pm

Postby sean » Mon Apr 02, 2007 12:31 pm

Thanks Alec,


Yes, we've put in a few echo statements to test and they print out the result above the page when the upload fails. We've specified a valid mime database location.

the
Code: Select all
$fi = finfo_open(FILEINFO_MIME, '/usr/share/file/magic');


seems to return "Resource id #28". Is this the problem?
sean
 
Posts: 37
Joined: Thu Mar 15, 2007 3:25 pm

Postby asmecher » Mon Apr 02, 2007 1:04 pm

Hi Sean,

No, that's behaving as it should. Try printing out the result of the call to:
Code: Select all
finfo_file($fi, $filename);
If this isn't identifying files properly, you might want to try a different mime database.

Regards,
Alec Smecher
Open Journal Systems Team
---
Don't miss the First International PKP Scholarly Publishing Conference
July 11 - 13, 2007, Vancouver, BC, Canada
http://ocs.sfu.ca/pkp2007/
asmecher
 
Posts: 8905
Joined: Wed Aug 10, 2005 12:56 pm

Postby sean » Mon Apr 02, 2007 1:35 pm

Code: Select all
finfo_file($fi, $filename);


returns image/png (the correct type) and yet I still get the invalid file type error. I tried other mime databases and it still doesn't work. Any ideas? Thanks
sean
 
Posts: 37
Joined: Thu Mar 15, 2007 3:25 pm

Postby asmecher » Mon Apr 02, 2007 2:11 pm

Hi Sean,

It sounds to me like this function is working as it should -- perhaps the problem is to do with file permissions. Check your server log to see if anything appears there, or try adding the following to index.php near the top:
Code: Select all
ini_set('display_errors', E_ALL);
If file permissions are the problem, trying to upload the file should generate an informative message. Where that message goes depends on your system configuration.

Regards,
Alec Smecher
Open Journal Systems Team
---
Don't miss the First International PKP Scholarly Publishing Conference
July 11 - 13, 2007, Vancouver, BC, Canada
http://ocs.sfu.ca/pkp2007/
asmecher
 
Posts: 8905
Joined: Wed Aug 10, 2005 12:56 pm

PreviousNext

Return to OJS Technical Support

Who is online

Users browsing this forum: Google [Bot] and 6 guests