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

TOPIC:

mime type - working in sandbox but not on my site 07 Sep 2015 17:46 #13441

Hello,

I cooked a component in which a user uploades an audio file. In table I used file and allowed mp3 (audio/mpeg). I can upload an mp3 in sandbox without a problem, but on my site it is not working anymore. I get
Mime type not valid (), allowed Mimes are audio/mpeg :
Impossible to upload file : 01.mp3

I also added mp3 and audio/mpeg to joomla media properties without any change. What can I do?
Thank you in advance.

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

mime type - working in sandbox but not on my site 09 Sep 2015 09:38 #13445

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 986
There are severals possibles ways to detect mime in php. Your component is trying the one it found possible, but it depends of your server configuration. Check your php modules.
If it fails only with a certain type of files, then the problem do not comes from your component.
Check the header of your MP3 file you try to upload.

Mime check is not a security safe check because the file header can be edited by hand.
It only helps for the ergonomy to avoid uploading a corrupted file, but you can avoid it.

Mime type detection occurs in :
classes/file/upload.php
Function checkMime()
protected function checkMime($fileMime)
{
	// Hack here
	return true;

	$valid = false;
	if (isset($this->allowedTypes) && count($this->allowedTypes))
	foreach($this->allowedTypes as $mime => $ext)
	{
		$mime = preg_replace("#\/#", "\\\/", $mime);
		if (preg_match("/" . $mime . "/", $fileMime))
			$valid = true;
	}
	return $valid;
}
Coding is now a piece of cake

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

Last edit: by admin.

mime type - working in sandbox but not on my site 09 Sep 2015 10:03 #13446

Now I get
JFile: :read: The file can not be opened: /tmp/phpGoJhZU
Warning! - The file can not be moved!

I don't have problems with uploading in other components and the folder is writable.

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

mime type - working in sandbox but not on my site 09 Sep 2015 10:34 #13447

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 986
Not only the CHMOD, check also the owner of the folder tmp.

in case, try chmod 777 (just for trying)
Coding is now a piece of cake

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

mime type - working in sandbox but not on my site 09 Sep 2015 11:12 #13448

I found the problem. I am using RS!Firewall which blocked the upload of mp3 files. I am very sorry! Thank you for your quick help.

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

mime type - working in sandbox but not on my site 09 Sep 2015 11:51 #13449

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 986
Great
Coding is now a piece of cake

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

mime type - working in sandbox but not on my site 10 Sep 2015 12:52 #13451

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 986
New documentation...

Here the full explaination :
www.j-cook.pro/index.php/m/mime-type
Coding is now a piece of cake

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

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

I have to say your builder is great! We use for another project in a week we have the system built. For the J!Boleto I convert to j3 in 2 weeks :)
Luiz Felipe Weber 

Get Started