Dolibarr/dolibarr · error
ErrorFileDoesNotExists
Error message
ErrorFileDoesNotExists : ${original_file} What it means
After resolving the file path, document.php checks file_exists() on the OS-encoded full path and, when the file is missing, prints the localized 'ErrorFileDoesNotExists : <file>' and exits. It is a defensive existence check before streaming the file from htdocs/document.php:353-357.
Solutions
- Verify the file actually exists at DOL_DATA_ROOT/<modulepart>/... for the given entity
- Check modulepart and original_file parameters match how the file was stored (list the dir with ls)
- Check multicompany entity configuration — the path depends on $conf->entity
- Fix OS locale/charset (dol_osencode) if the filename contains non-ASCII characters
- Regenerate the link, ideally using the hashp shared-link parameter which resolves via llx_ecm_files
Example fix
// before
$file = $conf->facture->dir_output.'/'.$facid.'/pdf.pdf'; // guessed path
// after
include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
if (!dol_is_file($file)) { setEventMessages('FileMissing: '.$file, null, 'errors'); } Defensive patterns
Strategy: validation
Validate before calling
$path = dol_osencode($fullpath); if (!is_file($path)) { die('File missing: '.$fullpath); } Type guard
function fileExists(string $fullpath): bool { return is_file(dol_osencode($fullpath)); } Prevention
- Check dol_is_file() before generating download links
- Keep links in sync with the storage: regenerate links after migrations/cleanup jobs
- Verify entity/multicompany directory matches the link's context
- Use ASCII-safe or properly encoded filenames consistent with OS locale
When it happens
Trigger: Request to document.php where the composed path $fullpath_original_file_osencoded does not exist on disk: wrong modulepart, wrong original_file, file deleted/moved, wrong entity/multicompany dir, or filesystem encoding mismatch between UTF-8 name and OS encoding.
Common situations: Files removed by cleanup jobs while links persist; multicompany setups pointing at the wrong entity directory; documents stored on external storage not mounted; non-ASCII filenames saved with a different charset than the OS locale.
Understand the failure class
Background: "File not found" and ENOENT errors: why libraries can't find a file that should exist — this error's family across 50 libraries.
Related errors
- ErrorFileNameInvalid
- ErrorDownloadDocumentHooks
- If define NOREQUIREDB or NOREQUIRETRAN are set, you must…
- If define NOREQUIREUSER is set, you must also set…
- Sorry, your application is offline.
AI-assisted analysis of Dolibarr/dolibarr@598aa4bdad (2026-09-14).
Data as JSON: /api/errors/e9a53b6a16959f88.
Report an issue: GitHub.
Appendix: source
Thrown at htdocs/document.php:356
dol_syslog("Refused to deliver file ".$fullpath_original_file);
print "ErrorFileNameInvalid: ".dol_escape_htmltag($original_file);
exit;
}
clearstatcache();
$filename = basename($fullpath_original_file);
$filename = preg_replace('/\.noexe$/i', '', $filename);
// Output file on browser
dol_syslog("document.php download $fullpath_original_file filename=$filename content-type=$type");
$fullpath_original_file_osencoded = dol_osencode($fullpath_original_file); // New file name encoded in OS encoding charset
// This test if file exists should be useless. We keep it to find bug more easily
if (!file_exists($fullpath_original_file_osencoded)) {
dol_syslog("ErrorFileDoesNotExists: ".$fullpath_original_file);
print $langs->trans("ErrorFileDoesNotExists") . ' : ' . dol_escape_htmltag($original_file);
exit;
}
// Hooks
$hookmanager->initHooks(array('document'));
$parameters = array('ecmfile' => $ecmfile, 'modulepart' => $modulepart, 'original_file' => $original_file,
'entity' => $entity, 'fullpath_original_file' => $fullpath_original_file,
'filename' => $filename, 'fullpath_original_file_osencoded' => $fullpath_original_file_osencoded);
$object = new stdClass();
$reshook = $hookmanager->executeHooks('downloadDocument', $parameters, $object, $action); // Note that $action and $object may have been
if ($reshook < 0) {
$errors = $hookmanager->error.(is_array($hookmanager->errors) ? (!empty($hookmanager->error) ? ', ' : '').implode(', ', $hookmanager->errors) : '');
dol_syslog("document.php - Errors when executing the hook 'downloadDocument' : ".$errors);
print "ErrorDownloadDocumentHooks: ".$errors;
exit;
}
// Set this for testView on GitHub (pinned to 598aa4bdad)