Not logged in. · Lost password · Register
Forum: General Help and Support Features and Functionality RSS
Upload doesn't match extension
Avatar
dglass #1
Member since Sep 2007 · 6 posts
Group memberships: Members
Show profile · Link to this post
Subject: Upload doesn't match extension
I've installed DokuWiki, and just about everything is working as expected. :)  The one thing that isn't is file upload.

When I try to upload a jpeg with either .jpg or .jpeg as the extension a message appears on the media manager page that reads:

The uploaded content did not match the .jpg file extension.

Obviously, the file does not get uploaded.

I thought it might be a permissions issue, but uploading of .zip and .pdf worked; those were the only other two I tried.

Any guidance would be appreciated.
Avatar
tobi@ini.phys.ethz.ch #2
Member since Sep 2007 · 3 posts · Location: zurich
Group memberships: Members
Show profile · Link to this post
I have the same problem - can upload pdf but not images like jpg or gif.
my conf/mime.conf seems ok (didn't change it). Another post to the issue tracker
http://bugs.splitbrain.org/index.php?do=details&task_i…
suggests a possible problem with php temp folder but i can't see why that wouldn't also affect pdf files.

Issue 1199
http://bugs.splitbrain.org/index.php?do=details&task_i…
suggests that this was closed, but it looks like something is not right for us too.
Avatar
tobi@ini.phys.ethz.ch #3
Member since Sep 2007 · 3 posts · Location: zurich
Group memberships: Members
Show profile · Link to this post
I was able to add the image by scp'ing it to the media folder and then it shows up, but sans metadata icon.

We have another dokuwiki wiki on the same server in which image media upload works fine. Still don't understand why it doesn't work on this wiki. Maybe some permissions thing?
Avatar
tobi@ini.phys.ethz.ch #4
Member since Sep 2007 · 3 posts · Location: zurich
Group memberships: Members
Show profile · Link to this post
The problem has to do with the tmp folder, i think. I worked around it for my private wiki by modifying the inc/media.php function media_contentcheck as follows

   if(substr($mime,0,6) == 'image/'){
        $info = getimagesize($file);
        if($mime == 'image/gif' && $info[2] != 1){
            msg(sprintf('php function getimagesize(%s) does not think this is an image/gif file (info[2]=%d) even though %s is the mime type',$file,$info[2],$mime));
            return 0;
        }elseif($mime == 'image/jpeg' && $info[2] != 2){
            msg(sprintf('php function getimagesize(%s) does not think this is an image/jpeg file (info[2]=%d) even though %s is the mime type',$file,$info[2],$mime));
            return 0;
        }elseif($mime == 'image/png' && $info[2] != 3){
            msg(sprintf('php function getimagesize(%s) does not think this is an image/png file (info[2]=%d) even though %s is the mime type',$file,$info[2],$mime));
            return 0;
        }

This function used to return -1 if the info[2] didn't return the right type. Now I just return 0 and show a msg. The debug messages printed out show

php function getimagesize(/srv/www/www.ini.unizh.ch/tmp/phpQu74yf) does not think this is an image/jpeg file (info[2]=0) even though image/jpeg is the mime type

What's going on here? Is this the problem referred to in http://bugs.splitbrain.org/index.php?do=details&task_i… ?
Avatar
dglass #5
Member since Sep 2007 · 6 posts
Group memberships: Members
Show profile · Link to this post
Thanks for posting that!  :)

Now I can get images uploaded.
Avatar
jjcuk25 #6
Member since Sep 2008 · 1 post
Group memberships: Members
Show profile · Link to this post
I note this bug is still unconfirmed FS#1232 - File upload gives wrong error with open_basedir
I can confirm I am having the same problem,
and thanks to tobi@ini.phys.ethz.ch  his fix works
Avatar
anomie #7
Member since Oct 2008 · 1 post
Group memberships: Members
Show profile · Link to this post
In reply to post #1
Quote by dglass on 2007-09-21, 18:21:
I've installed DokuWiki, and just about everything is working as expected. :)  The one thing that isn't is file upload.

When I try to upload a jpeg with either .jpg or .jpeg as the extension a message appears on the media manager page that reads:

The uploaded content did not match the .jpg file extension.

Same problem/symptoms here. I was able to upload .pdf files, but not e.g. .gif and .png files. This is on a RHEL 4.7 server with: apache 2.0, php4, dokuwiki 2008-05-05.

This does seem to be directly related to FS#1232 (http://bugs.splitbrain.org/index.php?do=details&task_i…).

As an alternative to modifying any of the dokuwiki php code, you can modify your php.ini settings such that your upload_tmp_dir is under your open_basedir directory. Example from my php.ini:
open_basedir = /var/www/doku
upload_tmp_dir = /var/www/doku/tmp-php

Ownership on /var/www/doku/tmp-php looks like:
[root@host]# ls -ld /var/www/doku/tmp-php
drwxrwxr-x  2 root apache 4096 Oct 23 11:09 /var/www/doku/tmp-php

Following these changes (after reloading httpd), my problems were solved, and uploading image files (.gif, .png) was working properly.
Avatar
ravendawson #8
Member since Dec 2010 · 2 posts
Group memberships: Members
Show profile · Link to this post
In reply to post #1
Quote by dglass on 2007-09-21, 18:21:
I've installed DokuWiki, and just about everything is working as expected. :)  The one thing that isn't is file upload.

When I try to upload a jpeg with either .jpg or .jpeg as the extension a message appears on the media manager page that reads:

The uploaded content did not match the .jpg file extension.

Obviously, the file does not get uploaded.

I thought it might be a permissions issue, but uploading of .zip and .pdf worked; those were the only other two I tried.

Any guidance would be appreciated.


I had this same problem before. When I try to upload an image with the media manager, i get the following error message :
"The uploaded content did not match the .png file extension."

Same result when i tried with a jpg file...but with a .txt file, there's no problem...

I think it may be due to an open_basedir restriction and an upload_tmp_dir dir outside of this restriction. Anyway, I've found this piece of information from faq that might be of help:

DokuWiki checks if uploaded files contain malicious content. To do this it needs access to uploaded file in the temporary upload directory. If your server uses PHP's open_basedir setting, you need to make sure your temporary upload directory is inside this basedir.

You can set the option to your DokuWiki temp dir. Either in your php.ini:

upload_tmp_dir = /path/to/dokuwiki/data/tmp
Avatar
FanjagNof #9
Member since Aug 2012 · 1 post
Group memberships: Members
Show profile · Link to this post
As I understand, this affects any php-code on the virtual web server and might therefore interfere with other applications.
Avatar
johan #10
Member since Jun 2012 · 8 posts · Location: The Netherlands
Group memberships: Members
Show profile · Link to this post
In reply to post #1
September 2012:
The problem still occurs in IE8 with Dokuwiki version Adora Belle.
However, when using Dokuwiki (I tried version Angua a while ago) on top of a local install of QuickPHP, all goes fine in IE8.
In FF, all goes fine.

I know nothing about PHP/JavaScript/BrowserImplementations, but this *seems* (gut feeling, nothing more) related to "interfacing" between IE8 and PHP. For some, it can be a dealbreaker for adopting Dokuwiki I guess. Who can track down the root of the problem?
Avatar
Michitux #11
Member since Apr 2008 · 377 posts · Location: Karlsruhe, Germany
Group memberships: Members, Wiki Managers
Show profile · Link to this post
I've just stumbled upon this thread because it was linked from another thread, I think your problem is the exactly same problem of the open_basedir setting.

The difference between IE8 and FF can be explained because IE8 doesn't use the new uploader library which doesn't use the PHP tempdir anymore.

It might actually be that uploads don't work at all anymore since DokuWiki version 2012-10-13 "Adora Belle" if the upload_tmp_dir is outside of the paths that are configured in the open_basedir setting because of this change.
Did you like my help or work for DokuWiki (plugins)? Consider giving something back.
Avatar
feed #12
User title: feed
Member since May 2013 · 15 posts · Location: Enschede, Netherlands
Group memberships: Members
Show profile · Link to this post
Subject: Upload doesn't match extension while open_basedir not used. Browser dependent.
Hi all,
July 12, 2013:

Some additional information on possibly the same problem:

Using Adora Belle I have problems uploading. Not just when uploading .png .jpg or .jpeg files, but also when uploading .zip or .pdf files.
I have 2 environments: Test and Production, with Production being the one with the problem :-(
They have different DW savedirs (set using the config manager).
So I thought: maybe an open_basedir problem.
However:
My /etc/apache2/php.ini and my /etc/cli/php.ini do not use open_basedir
Both Test and Production environments make use of the same php5 environment.

The problems do not occur when using Chrome or Mozillla FireFox 22.0
The problems do occur when using Firefox 9.0.1 or IE 9 version 9.0.8.112.16421, update version 9.0.17

I have not tried setting DW savedir to the same value yet.
I would like to trace the problem to the real cause, first.
Does anybody maybe have another clue or tip?

Either way, thanks for your attention!

Regards,
Harriet
Close Smaller – Larger + Reply to this post:
Verification code: VeriCode Please enter the word from the image into the text field below. (Type the letters only, lower case is okay.)
Smileys: :-) ;-) :-D :-p :blush: :cool: :rolleyes: :huh: :-/ <_< :-( :'( :#: :scared: 8-( :nuts: :-O
Special characters:
Go to forum
Imprint
This board is powered by the Unclassified NewsBoard software, 20150713-dev, © 2003-2015 by Yves Goergen
Current time: 2019-05-23, 03:50:15 (UTC +02:00)