forked from friendica/friendica-addons
Merge pull request #827 from nupplaphil/issue/6338-php_notices
[js_upload] Fixing missing extension index
This commit is contained in:
commit
c5ba1cae69
1 changed files with 126 additions and 122 deletions
|
@ -14,6 +14,7 @@
|
||||||
* Module Author: Chris Case
|
* Module Author: Chris Case
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use Friendica\Core\Config;
|
use Friendica\Core\Config;
|
||||||
use Friendica\Core\Hook;
|
use Friendica\Core\Hook;
|
||||||
use Friendica\Core\L10n;
|
use Friendica\Core\L10n;
|
||||||
|
@ -217,7 +218,7 @@ class qqUploadedFileXhr {
|
||||||
fclose($input);
|
fclose($input);
|
||||||
fclose($temp);
|
fclose($temp);
|
||||||
|
|
||||||
if ($realSize != $this->getSize()){
|
if ($realSize != $this->getSize()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@ -307,7 +308,7 @@ class qqFileUploader {
|
||||||
*/
|
*/
|
||||||
function handleUpload(){
|
function handleUpload(){
|
||||||
|
|
||||||
if (!$this->file){
|
if (!$this->file) {
|
||||||
return ['error' => L10n::t('No files were uploaded.')];
|
return ['error' => L10n::t('No files were uploaded.')];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -333,7 +334,10 @@ class qqFileUploader {
|
||||||
$pathinfo = pathinfo($this->file->getName());
|
$pathinfo = pathinfo($this->file->getName());
|
||||||
$filename = $pathinfo['filename'];
|
$filename = $pathinfo['filename'];
|
||||||
|
|
||||||
$ext = $pathinfo['extension'];
|
if (!isset($pathinfo['extension'])) {
|
||||||
|
Logger::warning('extension isn\'t set.', ['filename' => $filename]);
|
||||||
|
}
|
||||||
|
$ext = defaults($pathinfo, 'extension', '');
|
||||||
|
|
||||||
if($this->allowedExtensions && !in_array(strtolower($ext), $this->allowedExtensions)){
|
if($this->allowedExtensions && !in_array(strtolower($ext), $this->allowedExtensions)){
|
||||||
$these = implode(', ', $this->allowedExtensions);
|
$these = implode(', ', $this->allowedExtensions);
|
||||||
|
@ -342,13 +346,13 @@ class qqFileUploader {
|
||||||
|
|
||||||
if ($this->file->save()){
|
if ($this->file->save()){
|
||||||
return [
|
return [
|
||||||
'success'=>true,
|
'success' => true,
|
||||||
'path' => $this->file->getPath(),
|
'path' => $this->file->getPath(),
|
||||||
'filename' => $filename . '.' . $ext
|
'filename' => $filename . '.' . $ext
|
||||||
];
|
];
|
||||||
} else {
|
} else {
|
||||||
return [
|
return [
|
||||||
'error'=> L10n::t('Upload was cancelled, or server error encountered'),
|
'error' => L10n::t('Upload was cancelled, or server error encountered'),
|
||||||
'path' => $this->file->getPath(),
|
'path' => $this->file->getPath(),
|
||||||
'filename' => $filename . '.' . $ext
|
'filename' => $filename . '.' . $ext
|
||||||
];
|
];
|
||||||
|
|
Loading…
Reference in a new issue