OJS OCS OMP OHS

You are viewing the PKP Support Forum | PKP Home Wiki



Invalid homepage header title image format

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

Moderators: jmacgreg, michael, John

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

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. Please note that this FAQ is OJS-centric, but most issues are applicable to both platforms.

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 OCS Conference Support and Discussion subforum; if you have a development question, try the OCS Development subforum.

Invalid homepage header title image format

Postby tshore » Thu Mar 06, 2008 4:09 pm

I've found a few posts related to this problem, but I still can't fix it. Just installed the latest CVS on a new server (new to me).

http://www.prospectivememory.org/

PHP 5 and MySQL 5. When I try to upload a header image or a stylesheet, I get an error.

Errors occurred processing this form:
Invalid homepage header title image format. Accepted formats are .gif, .jpg, or .png.

It looks like it's a permission problem but I have everything under the public directory set to 777 (might not be wise, but I don't know what else to do to try to get it to work.

The header image actually got uploaded:

http://www.prospectivememory.org/public ... eImage.gif

but I can't get the site to use it. Also, although the Title Image radio button is selected, there is no filename listed.

Help please.
tshore
 
Posts: 264
Joined: Fri Nov 18, 2005 12:48 pm
Location: Hamilton, Ontario

Re: Invalid homepage header title image format

Postby jmacgreg » Thu Mar 06, 2008 10:19 pm

Hi Trudy,

Have you investigated whether it's a mime_type issue at all? I've found one similar reference in our bug database <http://pkp.sfu.ca/bugzilla/show_bug.cgi?id=2776>, and other references on the forums pointing to permissions (which I would agree isn't the problem here, especially as the item is being uploaded), or to mime type configuration issues.

James
jmacgreg
 
Posts: 4190
Joined: Tue Feb 14, 2006 10:50 am

Re: Invalid homepage header title image format

Postby tshore » Fri Mar 07, 2008 12:05 am

I have no idea how to investigate "whether it's a mime_type issue"? I do know that it happened when I tried to upload a stylesheet as well. I also had this happen on one of my other servers, so I just started uploading stylesheet changes manually, but I can't seem to pull that off for this installation. Nor can I do anything with the header images. I really need to show my client this site today. Please help.
tshore
 
Posts: 264
Joined: Fri Nov 18, 2005 12:48 pm
Location: Hamilton, Ontario

Re: Invalid homepage header title image format

Postby asmecher » Fri Mar 07, 2008 12:14 am

Hi tshore,

It sounds to me like your PHP installation doesn't have its mime_content_type function properly configured. See http://www.php.net/manual/en/function.mime-content-type.php for details on this function and its configuration. This forum also has a number of related discussions -- try searching for mime_content_type.

Regards,
Alec Smecher
Public Knowledge Project Team
asmecher
 
Posts: 8844
Joined: Wed Aug 10, 2005 12:56 pm

Re: Invalid homepage header title image format

Postby tshore » Mon Mar 10, 2008 1:30 am

I asked my webhost to add this line to their php.ini file:

mime_magic.magicfile = "/usr/share/magic.mime"

and I saw somewhere else that also adding this line might help:

mime_magic.debug = Off

But they refused. Here is their reply to me:

We apologize for the inconvenience but setting the mime_magic file is not possible for you on our system because this requires changing php.ini file that will affect other domains on the server. You can set your own mime type handlers in .htaccess files using directives similar to the following: AddType image/gif .gif

I tried this, but, as I suspected, it doesn't help.

Please tell me how I can do this directly by uploading the images (and stylesheet) via FTP, including what directory to put them in and what they need to be called. Also, what do I need to do in the database?

Thank you.
tshore
 
Posts: 264
Joined: Fri Nov 18, 2005 12:48 pm
Location: Hamilton, Ontario

Re: Invalid homepage header title image format

Postby asmecher » Mon Mar 10, 2008 9:16 am

Hi tshore,

This is worth spending a little bit of time getting fixed, as it'll affect you in numerous places in OJS. If the mime_content_type appears to work but doesn't function properly in your host's PHP configuration, OJS will use it -- but there are alternatives available that you can instruct OJS to use instead.

Look in classes/core/String.inc.php in the "mime_content_type" function (near line 212, depending on your version of OJS). There should be a line reading:
Code: Select all
if (function_exists('mime_content_type')) {
To instruct OJS not to use PHP's mime_content_type function, change this to the following:
Code: Select all
if (false && function_exists('mime_content_type')) {
This will instruct OJS to use one of two additional methods, which may have their own configuration or permission issues -- but we'll work on those once you've checked this to see if it works.

Regards,
Alec Smecher
Public Knowledge Project Team
asmecher
 
Posts: 8844
Joined: Wed Aug 10, 2005 12:56 pm

Re: Invalid homepage header title image format

Postby tshore » Tue Mar 11, 2008 2:29 am

Didn't help. Same error.
tshore
 
Posts: 264
Joined: Fri Nov 18, 2005 12:48 pm
Location: Hamilton, Ontario

Re: Invalid homepage header title image format

Postby asmecher » Fri Mar 14, 2008 5:57 am

Hi tshore,

You may have to do some investigation into your server to find out which methods are available for determining MIME types. OJS uses these three, in order:
  • The mime_content_type function (which you've now disabled)
  • The fileinfo toolset (e.g. the finfo_open function)
  • The external "file" tool, executed e.g. "file -bi /path/to/file"
These are implemented in the mime_content_type function in classes/core/String.inc.php -- I would step through this by checking your server to see which it supports, then picking one in particular to debug in OJS.

Regards,
Alec Smecher
Public Knowledge Project Team
asmecher
 
Posts: 8844
Joined: Wed Aug 10, 2005 12:56 pm

Re: Invalid homepage header title image format

Postby gdhnz » Tue Mar 18, 2008 2:28 pm

Hi tshore,

Did you get this resolved? I'm having the same problem on a fresh install of the latest cvs version on OS X with php 5.2.5 and apache 2. I also tried the latest non-cvs version.

If the mime_content_type (deprecated) and finfo_open (I don't want to have to compile and install an alpha libmagic library to get the fileinfo pecl extension working) fail, is there anything I need to set in a php.ini file for it to use the external "file" command?
gdhnz
 
Posts: 1
Joined: Tue Mar 18, 2008 1:50 pm

Re: Invalid homepage header title image format

Postby schiette » Fri Nov 28, 2008 6:21 am

Hi,

I installed OCS-2.1.1-2 couple of days ago, and I'm having the same problem. OCS is installed on a remote server running Fedora, PHP 5.0.4, Apache 2.0.54 and MySQL 4.1.20. I tried many things suggested in OCS and OJS boards, including adding an .htaccess file with AddType entries, but it didn't solve the problem.

Trying to debug, I found that the function mime_content_type($filename) receives as argument something like /tmp/phpIFI7sP where the underlined part is randomly variable. It thus appears that the image is loaded in a temporary file without extension, and this file name is interpreted as text/plain by function mime_content_type($filename), resulting in the error message.

I'm new to php (but not to programming). I looked around to see if it could be due to php.ini configuration or something like that but didn't found anything. Any suggestions?
schiette
 
Posts: 7
Joined: Thu Nov 27, 2008 4:10 pm

Re: Invalid homepage header title image format

Postby schiette » Fri Nov 28, 2008 10:27 am

Follow up on my previous message: I finally solved the problem by replacing, in function getUploadedFileType($fileName), the following line:
Code: Select all
$type = String::mime_content_type($_FILES[$fileName]['tmp_name']);
by
Code: Select all
$type = String::mime_content_type($_FILES[$fileName]['name']);
so the actual file name, with extension, is passed as argument to function mime_content_type() rather than the temporary file name that has no extension.

Is there is any potential problem in doing that? Is there a better solution by changing some configuration file on the server or something else?

Thanks for this great application!

François
schiette
 
Posts: 7
Joined: Thu Nov 27, 2008 4:10 pm

Re: Invalid homepage header title image format

Postby asmecher » Fri Nov 28, 2008 11:31 am

Hi François,

I'm surprised that the change you describe worked -- IIRC $_FILES[$fileName]['name'] refers to the filename that was used on your client machine, $_FILES[$fileName]['tmp_name'] refers to the temporary name the file has been uploaded to on your server. Unless for some reason your implementation of mime_content_type is only checking the file's name and not its contents (which is potentially dangerous), I don't think that will work as expected.

Regards,
Alec Smecher
Public Knowledge Project Team
asmecher
 
Posts: 8844
Joined: Wed Aug 10, 2005 12:56 pm

Re: Invalid homepage header title image format

Postby JoaoRMO » Sat Aug 16, 2014 7:13 pm

Adorei a solução de mudar a Lib/pkp/classes/file/FileManager.inc.php

PERFECT = OK :D
$type = String::mime_content_type($_FILES[$fileName]['tmp_name']);

$type = String::mime_content_type($_FILES[$fileName]['name']);



Se houver algum problema me avise, por favor:

If you had some problems contact me, please:
JoaoRMO
 
Posts: 1
Joined: Sat Aug 16, 2014 7:08 pm


Return to OCS Technical Support

Who is online

Users browsing this forum: No registered users and 1 guest