Welcome, Guest
Username: Password: Remember me

TOPIC: [SOLVED] mime type - working in sandbox but not on my site

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.
The administrator has disabled public write access.

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

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 987
  • Karma: 140
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
Last Edit: 09 Sep 2015 09:40 by admin.
The administrator has disabled public write access.

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.
The administrator has disabled public write access.

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

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 987
  • Karma: 140
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
The administrator has disabled public write access.

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.
The administrator has disabled public write access.

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

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 987
  • Karma: 140
Great
Coding is now a piece of cake
The administrator has disabled public write access.

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

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

Here the full explaination :
www.j-cook.pro/index.php/m/mime-type
Coding is now a piece of cake
The administrator has disabled public write access.
Time to create page: 0.151 seconds

Get Started