Fix can't create files on shared folder (Windows)

This commit is contained in:
Tobias Sekan 2019-11-29 07:46:39 +01:00 committed by GitHub
parent b820234870
commit f304dd424b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1807,17 +1807,29 @@ class TCPDF_STATIC {
/** /**
* Wrapper to use fopen only with local files * Wrapper to use fopen only with local files
* @param filename (string) Name of the file to open * @param string $filename The full path to the file to open
* @param $mode (string) * @param string $mode Acceses type for the file ('r', 'r+', 'w', 'w+', 'a', 'a+', 'x', 'x+', 'c', 'c+' or 'e')
* @return Returns a file pointer resource on success, or FALSE on error. * @return resource Returns a file pointer resource on success, or FALSE on error.
* @public static * @public static
*/ */
public static function fopenLocal($filename, $mode) { public static function fopenLocal($filename, $mode)
if (strpos($filename, '://') === false) { {
if (strpos($filename, '//') === 0)
{
// Share folder on a (windows) server
// e.g.: "//[MyServerName]/[MySharedFolder]/"
//
// nothing to change
}
elseif (strpos($filename, '://') === false)
{
$filename = 'file://'.$filename; $filename = 'file://'.$filename;
} elseif (stream_is_local($filename) !== true) { }
elseif (stream_is_local($filename) !== true)
{
return false; return false;
} }
return fopen($filename, $mode); return fopen($filename, $mode);
} }