啞劇「圖像/ JPEG」在這一點上,我很困惑的東西的圖像稱爲這-thing.png(如PNG24創造出來的Photoshop CS5的 ),作爲image/jpeg
上傳到kcfinder
。PHP PNG圖像上載與KCFINDER 3.12
與TriID分析,示出的圖像是完全100%PNG
C:\TrID>trid C:\users\michael\downloads\this-thing.png
TrID/32 - File Identifier v2.20 - (C) 2003-15 By M.Pontello
Definitions found: 3790
Analyzing...
Collecting data from file: C:\users\michael\downloads\this-thing.png
100.0% (.PNG) Portable Network Graphics (16000/1)
但是,當內$ _FILES可變數據[(鍵($ _ FILES)] [ 'tmp_name的值'],達到kcfinder \ core \ class \ browser.php函數moveUploadFile(作爲參數$文件)... mm類型從tm p_name以JPEG形式出現,而不是以PNG形式出現。
修飾功能,用於測試目的,包括從getimagesize() not returning false
protected function moveUploadFile($file, $dir) {
$message = $this->checkUploadedFile($file);
if ($message !== true) {
if (isset($file['tmp_name']))
@unlink($file['tmp_name']);
return "{$file['name']}: $message";
}
$filename = $this->normalizeFilename($file['name']);
$target = "$dir/" . file::getInexistantFilename($filename, $dir);
echo "<h3>PHP_FILES foreach</h3>";
foreach ($_FILES['upload']['name'] as $key => $value){
echo "<pre>";
print_r(getimagesize($_FILES['upload']['tmp_name'][$key]));
echo "</pre>";
}
echo "<h3>TEMP FILE</h3>";
echo "</strong>file variable</strong>";
echo "<pre>";
print_r($file);
echo "</pre>";
echo "</strong>file.tmp_name</strong>";
echo "<pre>";
print_r($file['tmp_name']);
echo "</pre>";
$tmp_name_imagesize = getimagesize($file['tmp_name']);
echo "<pre>";
print_r($tmp_name_imagesize);
echo "</pre>";
if (imagetypes() & IMG_PNG) { echo "PNG Supported"; } else { echo "PNG not supported."; }
// mkaatman - move tmp file to /tmp/ to check its MD5SUM result
$temporary_file_path = $file['tmp_name'] . ".uploaded";
move_uploaded_file($file['tmp_name'], $temporary_file_path);
die();
}
結果代碼,文件的上傳期間此-thing.png,表明該媒體類型是實際上JPG和不是PNG(這是部分,我似乎無法包裹我的頭)。
http://iforce.co.nz/i/kgcgf2af.pyo.png
顯然,這個文件php92C2.tmp.uploaded
是上傳的文件,到/tmp/
目錄。
我已經加入.png
到文件的末尾,使用Windows Rename
,文件分析的目的。
C:\TrID>trid C:\users\michael\downloads\php92C2.tmp.uploaded.png
TrID/32 - File Identifier v2.20 - (C) 2003-15 By M.Pontello
Definitions found: 3790
Analyzing...
Collecting data from file: C:\users\michael\downloads\php92C2.tmp.uploaded.png
50.0% (.JPG) JFIF JPEG Bitmap (4003/3)
37.4% (.JPG) JPEG Bitmap (3000/1)
12.4% (.MP3) MP3 audio (1000/1)
但是,如果圖像是通過PHP直接測試(複製+粘貼到目錄)
<?php
$image_file = "this-thing.png";
$image_file_details = getimagesize($image_file);
echo "<pre>";
print_r($image_file_details);
echo "</pre>";
?>
結果,讀取該圖像是在-事實PNG。
Array
(
[0] => 800
[1] => 300
[2] => 3
[3] => width="800" height="300"
[bits] => 8
[mime] => image/png
)
內kcfinder /高速緩存/ base.js功能功能_.initUploadButton =函數中使用的形式()是你的基本,上傳形式。
<div id="upload" style="top:5px;width:77px;height:31px">
<form enctype="multipart/form-data" method="post" target="uploadResponse" action="browse.php?type=image&lng=en&opener=ckeditor&act=upload"><input type="file" name="upload[]" onchange="_.uploadFile(this.form)" style="height:31px" multiple="multiple" /><input type="hidden" name="dir" value="" /></form>
</div>
最後從KCFINDER.Config從php
CONFIG.imageDriversPriority
imagick gmagick gd
CONFIG.deniedExts
exe com msi bat php phps phtml php3 php4 cgi pl htaccess htm html
CONFIG.types
Array
(
[image] => 7z aiff asf avi bmp csv doc fla flv gif gz gzip jpeg jpg mid mov mp3 mp4 mpc mpeg mpg ods odt pdf png ppt pxd qt ram rar rm rmi rmvb rtf sdc sitd swf sxc sxw tar tgz tif tiff txt vsd wav wma wmv xls xml zip
[images] => 7z aiff asf avi bmp csv doc fla flv gif gz gzip jpeg jpg mid mov mp3 mp4 mpc mpeg mpg ods odt pdf png ppt pxd qt ram rar rm rmi rmvb rtf sdc sitd swf sxc sxw tar tgz tif tiff txt vsd wav wma wmv xls xml zip
[files] => 7z aiff asf avi bmp csv doc fla flv gif gz gzip jpeg jpg mid mov mp3 mp4 mpc mpeg mpg ods odt pdf png ppt pxd qt ram rar rm rmi rmvb rtf sdc sitd swf sxc sxw tar tgz tif tiff txt vsd wav wma wmv xls xml zip
[uploads] => 7z aiff asf avi bmp csv doc fla flv gif gz gzip jpeg jpg mid mov mp3 mp4 mpc mpeg mpg ods odt pdf png ppt pxd qt ram rar rm rmi rmvb rtf sdc sitd swf sxc sxw tar tgz tif tiff txt vsd wav wma wmv xls xml zip
[mimages] => *mime image/gif image/png image/jpeg
)
一些信息,基於所有這些信息,我似乎弄清楚不能爲什麼地球上的圖像被上傳爲PNG,回來作爲JPEG。
編輯:我已經測試,kcfinder使用從MSPAINT創建的圖像(這是它得到混亂)
所測試的PNG圖像。
結果(基於上面的代碼)。
C:\TrID>trid C:\users\michael\Pictures\breaking-bad.png
TrID/32 - File Identifier v2.20 - (C) 2003-15 By M.Pontello
Definitions found: 3790
Analyzing...
Collecting data from file: C:\users\michael\Pictures\breaking-bad.png
100.0% (.PNG) Portable Network Graphics (16000/1)
C:\TrID>
編輯:PNG支持(回覆爲馬克曼)
if (imagetypes() & IMG_PNG) {
echo "PNG Supported";
} else {
echo "PNG not supported.";
}
編輯:我發現,其中圖像被從PNG轉換爲JPG
如果checkUploadedFile
在期間被註釋掉文件this-thing.png
出來預期PNG ....
protected function checkUploadedFile(array $aFile=null) {
$config = &$this->config;
$file = ($aFile === null) ? $this->file : $aFile;
if (!is_array($file) || !isset($file['name']))
return $this->label("Unknown error");
if (is_array($file['name'])) {
foreach ($file['name'] as $i => $name) {
$return = $this->checkUploadedFile(array(
'name' => $name,
'tmp_name' => $file['tmp_name'][$i],
'error' => $file['error'][$i]
));
if ($return !== true)
return "$name: $return";
}
return true;
}
$extension = file::getExtension($file['name']);
$typePatt = strtolower(text::clearWhitespaces($this->types[$this->type]));
// CHECK FOR UPLOAD ERRORS
if ($file['error'])
return
($file['error'] == UPLOAD_ERR_INI_SIZE) ?
$this->label("The uploaded file exceeds {size} bytes.",
array('size' => ini_get('upload_max_filesize'))) : (
($file['error'] == UPLOAD_ERR_FORM_SIZE) ?
$this->label("The uploaded file exceeds {size} bytes.",
array('size' => $_GET['MAX_FILE_SIZE'])) : (
($file['error'] == UPLOAD_ERR_PARTIAL) ?
$this->label("The uploaded file was only partially uploaded.") : (
($file['error'] == UPLOAD_ERR_NO_FILE) ?
$this->label("No file was uploaded.") : (
($file['error'] == UPLOAD_ERR_NO_TMP_DIR) ?
$this->label("Missing a temporary folder.") : (
($file['error'] == UPLOAD_ERR_CANT_WRITE) ?
$this->label("Failed to write file.") :
$this->label("Unknown error.")
)))));
// HIDDEN FILENAMES CHECK
elseif (substr($file['name'], 0, 1) == ".")
return $this->label("File name shouldn't begins with '.'");
// EXTENSION CHECK
elseif (
(substr($file['name'], -1) == ".") ||
!$this->validateExtension($extension, $this->type)
)
return $this->label("Denied file extension.");
// SPECIAL DIRECTORY TYPES CHECK (e.g. *img)
elseif (preg_match('/^\*([^ ]+)(.*)?$/s', $typePatt, $patt)) {
list($typePatt, $type, $params) = $patt;
$class = __NAMESPACE__ . "\\type_$type";
if (class_exists($class)) {
$type = new $class();
$cfg = $config;
$cfg['filename'] = $file['name'];
if (strlen($params))
$cfg['params'] = trim($params);
$response = $type->checkFile($file['tmp_name'], $cfg);
if ($response !== true)
return $this->label($response);
} else
return $this->label("Non-existing directory type.");
}
// IMAGE RESIZE
$img = image::factory($this->imageDriver, $file['tmp_name']);
if (!$img->initError && !$this->imageResize($img, $file['tmp_name']))
return $this->label("The image is too big and/or cannot be resized.");
return true;
}
輸出爲PNG Supported.
這是什麼輸出? 'if(imagetypes()&IMG_PNG){echo「PNG Supported」; }其他{回聲「PNG不支持。」; }' – mkaatman
@mkaatman'PNG Supported' – Killrawr
如果是這樣,你的'var_dump($ file);'它是你期望的文件嗎?不知何故,我懷疑你運行的是錯誤的文件,或者你的某個方法正在改變文件。 'pp_array()'做什麼? – mkaatman