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.

Problems Uploading

Postby Stewie » Fri Feb 23, 2007 8:50 am

I am trying to upload a cover image and get the following error:
Warning: shell_exec() [function.shell-exec]: Unable to execute 'file -bi "C:\WINDOWS\TEMP\php7.tmp"' in C:\Inetpub\wwwroot\ojs\classes\core\String.inc.php on line 209

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

even though I get the error, the image still uploads.

I am using win2k3 server and OJS version 2.1.1.0.

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

Postby asmecher » Fri Feb 23, 2007 10:50 am

Hi Stewie,

It looks like your PHP installation is missing the standard mime_content_type function; OJS tries to use the external "file" tool to determine file types as a fallback, but it doesn't exist on the Windows platform. I'd investigate why the function is missing from your PHP install, as you'll probably encounter some problems without 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/
asmecher
 
Posts: 9083
Joined: Wed Aug 10, 2005 12:56 pm

Postby Stewie » Fri Feb 23, 2007 1:00 pm

I am rather new to PHP, and I am just setting this up for someone else so bare with me.
I have found on the php website that the mime_content_type function is now deprecated.

I found this post:
viewtopic.php?p=4925

but was not able to use that solution.

How would I go about enableing the mime_content_type function that you mentioned in that post?

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

Postby asmecher » Fri Feb 23, 2007 1:38 pm

Hi Stewie,

mime_content_type is indeed deprecated, but it should be part of any standard PHP install. Did you build your own version of PHP, or are you using one from a standard distribution? You may need to install a module in order for this function to work.

If you're able to install the fileinfo module, I can suggest some code to try.

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: 9083
Joined: Wed Aug 10, 2005 12:56 pm

Postby Stewie » Fri Feb 23, 2007 3:47 pm

I am using php version 5.2.1 which I got from the php website

Also I did add php_fileinfo.dll, is that the correct module to add?
Stewie
 
Posts: 23
Joined: Fri Feb 23, 2007 8:44 am

Postby asmecher » Sat Feb 24, 2007 11:38 pm

Hi Stewie,

If you built PHP from scratch, you'll need to configure it using the --with-mime-magic directive. This should build in the mime_content_type function.

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: 9083
Joined: Wed Aug 10, 2005 12:56 pm

Postby Stewie » Mon Feb 26, 2007 7:53 am

I downloaded it from the php website. http://www.php.net/

I downloaded it on Tuesday of last week. version 5.2.1
Stewie
 
Posts: 23
Joined: Fri Feb 23, 2007 8:44 am

Postby Stewie » Mon Feb 26, 2007 3:56 pm

Alec,

I did not build the php, I downloaded it from php.net so I would think it would have the mime_content_type function in there.

Now I know nothing of php, I work at a university and a department wanted this so I just installed it and it seemed to work except for this upload error that I get. But the files actually get uploaded because I can get to them in the folder on the server.

What would be the easiest way to build the mime_content_type function if it is missing?

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

Postby asmecher » Mon Feb 26, 2007 5:12 pm

Hi Stewie,

Hmm, I hadn't realized they'd already stopped including the mime_content_type function with binary distributions. Try replacing the mime_content_type function in classes/core/String.inc.php with:
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();
                        }
                        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;
        }
This is untested but should work. Please report your success back here. This modified version uses the fileinfo extension, if available.

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: 9083
Joined: Wed Aug 10, 2005 12:56 pm

Postby Stewie » Tue Feb 27, 2007 7:48 am

Alec,

I still got the same error.

Warning: shell_exec() [function.shell-exec]: Unable to execute 'file -bi "c:\ojsfiles\php1.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

I went to classes/core/String.inc.php and replaced
Code: Select all
   function mime_content_type($filename) {
      if (!function_exists('mime_content_type')) {
         $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;
       }
       return mime_content_type($filename);
     }

with your 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();
                        }
                        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;
        }

Any other suggestions?

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

Postby Stewie » Tue Feb 27, 2007 9:41 am

I have found a work around. One that I do not want to implement due to security reasons.
Here is the link to the article I found online
http://www.somacon.com/p255.php

What it suggested doing was giving isur read execute permission to the command line.

I tested it and it did work. but I am not sure that is the best way to fix the issue.

is there any other way you can think of?

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

Postby asmecher » Tue Feb 27, 2007 9:44 am

Hi Stewie,

If you still get the same message, it means that the fileinfo extension hasn't been properly enabled. The package is documented at http://www.php.net/manual/en/ref.fileinfo.php.

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: 9083
Joined: Wed Aug 10, 2005 12:56 pm

Postby Stewie » Tue Feb 27, 2007 9:49 am

Alec,

Did you see the link that I posted about giving access to cmd.exe for isur?

When I tried that the error message did not show up. but due to security reasons I really don't want give isur access to cmd.exe.

You ever seen anything like that or know of a differnet work around?

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

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

Hi Stewie,

The mime_content_type function posted above (the modified version, that is) follows this execution path:

1. If the mime_content_type function exists, use it. (This function does not exist in your version of PHP.)

2. Otherwise, if the fileinfo extension exists, use it. (This function does not currently exist in your version of PHP, but should be installed.)

3. Otherwise, try to execute the external "file" utility. (This function is a *NIX standard utility but does not exist in Windows.)

The only step that requires external execution privileges is the third, which is not relevant to your system if you've got the fileinfo extension installed. Besides, it's much better to use the internal tool for performance reasons. I'd suggest investigating why the fileinfo functions aren't installed; it will make execution permissions irrelevant.

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: 9083
Joined: Wed Aug 10, 2005 12:56 pm

Postby Stewie » Tue Feb 27, 2007 10:22 am

Hi Alec,

I do believe that I have fileinfo installed.
in PHP\ext I have php_fileinfo.dll

That was already in there I did not have to put it there.

in the php.ini file I added the line extensions=php_fileinfo.dll

after doing this I still got those 2 same error messages, but I also got a new one:

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

Any suggestions on that error?

Thank you so much for your help :)
Stewie
 
Posts: 23
Joined: Fri Feb 23, 2007 8:44 am

Next

Return to OJS Technical Support

Who is online

Users browsing this forum: Yahoo [Bot] and 3 guests