Welcome, Guest
Username: Password: Remember me
  • Page:
  • 1

TOPIC:

PHP 5.3 - Mime type not valid (application/force-download) 28 Oct 2012 22:05 #4815

[Note: This is solved in the respect that I got it to function. But how I got it to function is undesirable.]

Ok the component is working on the Cook sandbox, but it is not working on my dev server. The component will not allow me to upload a zip file on my own dev server. I get this error:

Mime type not valid (application/force-download), allowed Mimes are application/x-gzip - application/x-tar - text/plain - application/x-zip - application/x-compressed - application/x-zip-compressed :
Impossible to upload file : license.zip


So, I checked the Joomla mime types and added all of the different mime types for zip files on my dev server. Well, that didn't matter. Same error.

So I tried uploading a text file. (txt) Same problem.

I made sure that the MIME types are selected in the File properties on the table view in Cook.

What am I missing? I read the other articles about MIME types, but I'd rather not hack core files to get around this problem.

Ideas?

Note: No PHP errors are being generated on my dev server.

Joomla 2.5.7
PHP 5.3.18
DB Automatisms: Table
Cook: v2.0
--
Jerry Benton
The following user(s) said Thank You: JoomGuy

Please Log in or Create an account to join the conversation.

Last edit: by jcbenton.

PHP 5.3 - Mime type not valid (application/force-download) 28 Oct 2012 22:20 #4816

Update:

I switched to MooTools and tried again. Same error.
--
Jerry Benton

Please Log in or Create an account to join the conversation.

PHP 5.3 - Mime type not valid (application/force-download) 28 Oct 2012 22:47 #4817

administrator/components/com_sgm/classes/upload.php

If I comment out this section:
$this->file->mime = $this->getMime($this->file->tmp);
                if (!$this->checkMime($this->file->mime))
                {
                        $app->enqueueMessage(JText::sprintf( "SGM_UPLOAD_MIME_TYPE_NOT_VALID_ALLOWED_MIMES_ARE",
                                                                                                $this->file->mime,
                                                                                                $this->getAllowedMimes()), 'error');
                        return false;
                }


The upload works, but the file doesn't get the correct extension when stored.
--
Jerry Benton

Please Log in or Create an account to join the conversation.

PHP 5.3 - Mime type not valid (application/force-download) 28 Oct 2012 23:03 #4818

Might have the solution. My version of Apache was compiled without MIME Magic. I am recompiling now and will post results.


Update: Recompiled with MIME Magic enabled. No change. Same error.
--
Jerry Benton

Please Log in or Create an account to join the conversation.

Last edit: by jcbenton.

PHP 5.3 - Mime type not valid (application/force-download) 28 Oct 2012 23:58 #4820

Ok, I went through the functions used in Cook to figure out why this wasn't working. In short, none of the methods in the functions were able to find an available PHP function. (My server is locked down pretty tight. Only stuff that is needed is enabled.)

Some notes:

mime_content_type is deprecated in PHP 5.3.+

finfo_file
isn't as standardized as anyone would like it to be

system, shell_exec, and exec are typically disabled on my servers for really good reasons


So, if I have to pick one, I will go with shell_exec. I enabled it and the MIME detection now works correctly. So, what I am going to do now is recompile apache with Fileinfo enabled and try it. I will post the results. Hopefully it works so I can disable shell_exec again.
--
Jerry Benton

Please Log in or Create an account to join the conversation.

Last edit: by jcbenton.

PHP 5.3 - Mime type not valid (application/force-download) 29 Oct 2012 00:33 #4823

Ok, I recompiled apache again with finfo_file support. It is enabled and functioning.

I disabled shell_exec and tried uploading a file again.

Mime type not valid (application/zip), allowed Mimes are application/x-gzip - application/x-tar - text/plain - application/x-zip - application/x-compressed - application/x-zip-compressed :
Impossible to upload file : license.zip


So for now I will enable shell_exec so it will work, but hopefully the finfo_file will one day work.
--
Jerry Benton
The following user(s) said Thank You: JoomGuy

Please Log in or Create an account to join the conversation.

PHP 5.3 - Mime type not valid (application/force-download) 29 Oct 2012 20:41 #4828

  • JoomGuy
  • JoomGuy's Avatar
  • Offline
  • Moderator
  • Moderator
  • Joomla Enthusiast, Lover of Cooking
  • Posts: 1115
  • Thank you received: 195

jcbenton wrote: administrator/components/com_sgm/classes/upload.php

If I comment out this section:

$this->file->mime = $this->getMime($this->file->tmp);
                if (!$this->checkMime($this->file->mime))
                {
                        $app->enqueueMessage(JText::sprintf( "SGM_UPLOAD_MIME_TYPE_NOT_VALID_ALLOWED_MIMES_ARE",
                                                                                                $this->file->mime,
                                                                                                $this->getAllowedMimes()), 'error');
                        return false;
                }


The upload works, but the file doesn't get the correct extension when stored.

Have you tried overwriting the file name with {mimext} and other options? Check what's available and have a little play around...

Gez

P.S. Karma+1 for all your hard work debugging this and providing thorough explanation of your findings - i hope others might find this useful!!!

PPS Did you find BTB3000's post on mime types and if so, was it useful?
Need help with your Cook/Joomla Project? . PM me to find out what I can help with. NO time wasters please!!!

Please Log in or Create an account to join the conversation.

PHP 5.3 - Mime type not valid (application/force-download) 29 Oct 2012 20:44 #4829

Yes, all of the MIME features now work since I enabled shell_exec.

What I would like @admin to figure out is why finfo_file does not appear to be working. I enabled it, disabled shell_exec, and the upload failed. However, the function is available and working on my dev server.
--
Jerry Benton

Please Log in or Create an account to join the conversation.

PHP 5.3 - Mime type not valid (application/force-download) 29 Oct 2012 21:07 #4834

  • JoomGuy
  • JoomGuy's Avatar
  • Offline
  • Moderator
  • Moderator
  • Joomla Enthusiast, Lover of Cooking
  • Posts: 1115
  • Thank you received: 195

What I would like @admin to figure out is why finfo_file does not appear to be working

Do you mean on your server or cook sandbox? IF cook, then maybe it's running on < php 5.3 which is required.

If this is on your server, is it possible that there is some global that you are not actually able to override? Are you in php.ini or setting it programmatically?

BTW - not sure if this will be much help as the thread is not solved however, it may give you some other ideas...
www.j-cook.pro/forum/32-trouble-shooting...rking-mime-detection

Gez
Need help with your Cook/Joomla Project? . PM me to find out what I can help with. NO time wasters please!!!

Please Log in or Create an account to join the conversation.

PHP 5.3 - Mime type not valid (application/force-download) 29 Oct 2012 21:08 #4835

On my server. My PHP version is 5.3.18.

Yes, I read that article. In short, the error for both of us was in the PHP configuration. Well, an error in the sense that what needs to be enabled for this to work correctly in Cook.
--
Jerry Benton

Please Log in or Create an account to join the conversation.

Last edit: by jcbenton.

PHP 5.3 - Mime type not valid (application/force-download) 29 Oct 2012 21:15 #4836

  • JoomGuy
  • JoomGuy's Avatar
  • Offline
  • Moderator
  • Moderator
  • Joomla Enthusiast, Lover of Cooking
  • Posts: 1115
  • Thank you received: 195
Need help with your Cook/Joomla Project? . PM me to find out what I can help with. NO time wasters please!!!

Please Log in or Create an account to join the conversation.

PHP 5.3 - Mime type not valid (application/force-download) 01 Nov 2012 11:08 #4882

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 986
I must check on PHP 5.3.x as well.

I am soo late !
If you find the work aroud under 5.3.x, will offer Karma.

For the moment disable it.
Coding is now a piece of cake

Please Log in or Create an account to join the conversation.

Re: PHP 5.3 - Mime type not valid (application/force-download) 01 Nov 2012 11:20 #4885

  • JoomGuy
  • JoomGuy's Avatar
  • Offline
  • Moderator
  • Moderator
  • Joomla Enthusiast, Lover of Cooking
  • Posts: 1115
  • Thank you received: 195
Since ... is depreceated in PHP5.3, for the moment, won't something like this work @admin;
function checkMimeType($filename)
{
    $mimetype = false;
    if(function_exists('finfo_fopen')) {
        // open with FileInfo
    } elseif(function_exists('getimagesize')) {
        // open with GD
    } elseif(function_exists('exif_imagetype')) {
       // open with EXIF
    } elseif(function_exists('mime_content_type')) {
       $mimetype = mime_content_type($filename);
    }
    return $mimetype;
}

Alternatively, what about checking for the php version using phpversion(); then calling the functions accordingly?

Gez
Need help with your Cook/Joomla Project? . PM me to find out what I can help with. NO time wasters please!!!

Please Log in or Create an account to join the conversation.

Re: PHP 5.3 - Mime type not valid (application/force-download) 01 Nov 2012 11:37 #4891

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 986
In the source, it is more or less the same. The difference with cook is that you can custom the functions calls to use in a simple array, and/or test them in a different order.

As you said, it can be handled with version of PHP, even better.

And for 5.3.x, somebody has an answer ?
Not tested with "exif_imagetype". Does work on 5.3 ?
Coding is now a piece of cake

Please Log in or Create an account to join the conversation.

Re: PHP 5.3 - Mime type not valid (application/force-download) 01 Nov 2012 11:39 #4892

  • JoomGuy
  • JoomGuy's Avatar
  • Offline
  • Moderator
  • Moderator
  • Joomla Enthusiast, Lover of Cooking
  • Posts: 1115
  • Thank you received: 195
Not sure about exif_imagetype but isn't the finfo_fopen function the way to do it in 5.3?
Need help with your Cook/Joomla Project? . PM me to find out what I can help with. NO time wasters please!!!

Please Log in or Create an account to join the conversation.

  • Page:
  • 1
Time to create page: 0.100 seconds

Just wanted to congratulate you on the J-Cook website / web development tool. In a couple of visits I've had a play around with Cook and have to say I think it is fantastic.  I've played with a number of component builders in the past and yours is certainly looking like the best so far. I'd also like to help you spread the word - I'm really surprised more people aren't excited about this tool. Good luck with the project.
Dean

Get Started