From e74c6acdf61d7070de0ead0e013978d970c834e4 Mon Sep 17 00:00:00 2001 From: Neil Drumm Date: Thu, 27 Dec 2007 09:52:36 +0000 Subject: [PATCH] #180126 by mmoreno, drewish and scor: add realpath() call to file_save_data(), so Windows will create temporary files properly --- includes/file.inc | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/includes/file.inc b/includes/file.inc index dbb837540dd1..a1192edda35f 100644 --- a/includes/file.inc +++ b/includes/file.inc @@ -223,8 +223,9 @@ function file_check_upload($source = 'upload') { $file = new stdClass(); $file->filename = trim(basename($_FILES["files"]["name"][$source]), '.'); - // Create temporary name/path for newly uploaded files. - $file->filepath = tempnam(file_directory_temp(), 'tmp_'); + // Create temporary name/path for newly uploaded files. On Windows, tempnam() + // requires an absolute path, so we use realpath(). + $file->filepath = tempnam(realpath(file_directory_temp()), 'tmp_'); $file->filemime = $_FILES["files"]["type"][$source]; @@ -523,7 +524,8 @@ function file_save_upload($source, $dest = FALSE, $replace = FILE_EXISTS_RENAME) */ function file_save_data($data, $dest, $replace = FILE_EXISTS_RENAME) { $temp = file_directory_temp(); - $file = tempnam($temp, 'file'); + // On Windows, tempnam() requires an absolute path, so we use realpath(). + $file = tempnam(realpath($temp), 'file'); if (!$fp = fopen($file, 'wb')) { drupal_set_message(t('The file could not be created.'), 'error'); return 0;