Merge pull request #11544 from atm-josselin/FIX_upload_file_with_multiple_spaces

FIX : correct error in files with multiple spaces
This commit is contained in:
Laurent Destailleur 2019-07-25 17:48:26 +02:00 committed by GitHub
commit e8932335aa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1540,6 +1540,11 @@ function dol_add_file_process($upload_dir, $allowoverwrite=0, $donotupdatesessio
$info = pathinfo($destfile);
$destfile = dol_sanitizeFileName($info['filename'].'.'.strtolower($info['extension']));
// We apply dol_string_nohtmltag also to clean file names (this remove duplicate spaces) because
// this function is also applied when we make try to download file (by the GETPOST(filename, 'alphanohtml') call).
$destfile = dol_string_nohtmltag($destfile);
$destfull = dol_string_nohtmltag($destfull);
$resupload = dol_move_uploaded_file($TFile['tmp_name'][$i], $destfull, $allowoverwrite, 0, $TFile['error'][$i], 0, $varfiles);
if (is_numeric($resupload) && $resupload > 0) // $resupload can be 'ErrorFileAlreadyExists'