1
0
Fork 0

Improved Mime Type detection

This commit is contained in:
Michael 2020-04-01 05:42:44 +00:00
commit d3722c945b
9 changed files with 89 additions and 102 deletions

View file

@ -706,9 +706,7 @@ function photos_post(App $a)
return;
}
if ($type == "") {
$type = Images::guessType($filename);
}
$type = Images::getMimeTypeBySource($src, $filename, $type);
Logger::log('photos: upload: received file: ' . $filename . ' as ' . $src . ' ('. $type . ') ' . $filesize . ' bytes', Logger::DEBUG);

View file

@ -174,23 +174,7 @@ function wall_upload_post(App $a, $desktopmode = true)
exit();
}
// This is a special treatment for picture upload from Twidere
if (($filename == "octet-stream") && ($filetype != "")) {
$filename = $filetype;
$filetype = "";
}
if ($filetype == "") {
$filetype = Images::guessType($filename);
}
// If there is a temp name, then do a manual check
// This is more reliable than the provided value
$imagedata = getimagesize($src);
if ($imagedata) {
$filetype = $imagedata['mime'];
}
$filetype = Images::getMimeTypeBySource($src, $filename, $filetype);
Logger::log("File upload src: " . $src . " - filename: " . $filename .
" - size: " . $filesize . " - type: " . $filetype, Logger::DEBUG);