Closed (won't fix)
Project:
SWFUpload
Version:
5.x-2.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
24 Nov 2007 at 20:24 UTC
Updated:
20 May 2010 at 19:35 UTC
flash gives every kind of file an application/octet-stream mime-type. This gives problems with for example the slideshow.module which uses the mimetype for selecting images.
Adding something like this to _swfupload_swfupload() may do the trick:
// mime-type is always application/octet-stream when using flash for uploading
if($_FILES['Filedata']['type'] == 'application/octet-stream') {
if (function_exists('finfo_open')) {
$f = finfo_open(FILEINFO_MIME);
$mime = finfo_file($f, $_FILES['Filedata']['tmp_name']);
finfo_close($f);
$_FILES['Filedata']['type'] = $mime;
}
elseif (class_exists('finfo')) {
$f = new finfo(FILEINFO_MIME);
$_FILES['Filedata']['type'] = $f->file($_FILES['Filedata']['tmp_name']);
}
elseif (strlen($mime=@shell_exec("file -bi ".escapeshellarg($_FILES['Filedata']['tmp_name'])))!=0) {
//Using shell if unix an authorized
$_FILES['Filedata']['type'] = trim($mime);
}
elseif (function_exists('mime_content_type')) {
//Double check the mime-type with magic-mime if avaible
$_FILES['Filedata']['type'] = mime_content_type($_FILES['Filedata']['tmp_name']);
}
}
| Comment | File | Size | Author |
|---|---|---|---|
| mimetype.patch | 1.23 KB | casey |
Comments
Comment #1
boris mann commentedThis looks like a good addition. Marking as feature request for new code.
Comment #2
skilip commentedThe Drupal 5 branch will not be longer supported