|
@@ -58,7 +58,10 @@ class FileUpload {
|
|
|
|
|
|
if ($this->fileName) {
|
|
|
$this->fileName = $this->sanitizeFilename($this->fileName);
|
|
|
- $pathinfo = pathinfo($this->fileName);
|
|
|
+
|
|
|
+ //弃用原生pathinfo(),原因在低版本的php环境下无法正确读取文件名称。
|
|
|
+ //$pathinfo = pathinfo($this->fileName);
|
|
|
+ $pathinfo = $this->mb_pathinfo($this->fileName);
|
|
|
|
|
|
if (isset($pathinfo['extension']) &&
|
|
|
isset($pathinfo['filename']))
|
|
@@ -85,6 +88,15 @@ class FileUpload {
|
|
|
return substr(basename('X'.$splited[count($splited)-1], $suffix), 1);
|
|
|
}
|
|
|
|
|
|
+ private function mb_pathinfo($filepath) {
|
|
|
+ preg_match('%^(.*?)[\\\\/]*(([^/\\\\]*?)(\.([^\.\\\\/]+?)|))[\\\\/\.]*$%im',$filepath,$m);
|
|
|
+ if($m[1]) $ret['dirname']=$m[1];
|
|
|
+ if($m[2]) $ret['basename']=$m[2];
|
|
|
+ if($m[5]) $ret['extension']=$m[5];
|
|
|
+ if($m[3]) $ret['filename']=$m[3];
|
|
|
+ return $ret;
|
|
|
+ }
|
|
|
+
|
|
|
public function getFileName() {
|
|
|
return $this->fileName;
|
|
|
}
|