Commit 46abc88e authored by Dries's avatar Dries

- Patch #26249 by crunchywelch, Junyor: use upload_tmp_dir as default...

- Patch #26249 by crunchywelch, Junyor: use upload_tmp_dir as default temporary directory.  Fixed file problems on Windows NT systems.
parent a8b21882
......@@ -12,12 +12,10 @@
* Common file handling functions.
*/
define('IS_WINDOWS', substr(PHP_OS, 0, 3) == 'WIN');
define('FILE_DOWNLOADS_PUBLIC', 1);
define('FILE_DOWNLOADS_PRIVATE', 2);
define('FILE_CREATE_DIRECTORY', 1);
define('FILE_MODIFY_PERMISSIONS', 2);
define('FILE_DIRECTORY_TEMP', IS_WINDOWS ? 'c:\\windows\\temp' : '/tmp');
define('FILE_EXISTS_RENAME', 0);
define('FILE_EXISTS_REPLACE', 1);
define('FILE_EXISTS_ERROR', 2);
......@@ -59,7 +57,7 @@ function file_create_path($dest = 0) {
return $dest;
}
// check if the destination is instead inside the Drupal temporary files directory.
else if (file_check_location($dest, variable_get('file_directory_temp', FILE_DIRECTORY_TEMP))) {
else if (file_check_location($dest, variable_get('file_directory_temp', ini_get('upload_tmp_dir')))) {
return $dest;
}
// Not found, try again with prefixed dirctory path.
......@@ -363,7 +361,7 @@ function file_save_upload($source, $dest = 0, $replace = FILE_EXISTS_RENAME) {
// Make sure $source exists in $_FILES.
if ($file = file_check_upload($source)) {
if (!$dest) {
$dest = variable_get('file_directory_temp', FILE_DIRECTORY_TEMP);
$dest = variable_get('file_directory_temp', ini_get('upload_tmp_dir'));
$temporary = 1;
if (is_file($file->filepath)) {
// If this file was uploaded by this user before replace the temporary copy.
......@@ -421,7 +419,7 @@ function file_save_data($data, $dest, $replace = FILE_EXISTS_RENAME) {
return 0;
}
$temp = variable_get('file_directory_temp', FILE_DIRECTORY_TEMP);
$temp = variable_get('file_directory_temp', ini_get('upload_tmp_dir'));
$file = tempnam($temp, 'file');
if (!$fp = fopen($file, 'wb')) {
drupal_set_message(t('The file could not be created.'), 'error');
......
......@@ -325,7 +325,7 @@ function system_view_general() {
'#description' => t('A file system path where the files will be stored. This directory has to exist and be writable by Drupal. If the download method is set to public this directory has to be relative to Drupal installation directory, and be accessible over the web. When download method is set to private this directory should not be accessible over the web. Changing this location after the site has been in use will cause problems so only change this setting on an existing site if you know what you are doing.')
);
$directory_temp = variable_get('file_directory_temp', FILE_DIRECTORY_TEMP);
$directory_temp = variable_get('file_directory_temp', ini_get('upload_tmp_dir'));
file_check_directory($directory_temp, FILE_CREATE_DIRECTORY, 'file_directory_temp');
$form['files']['file_directory_temp'] = array(
......
......@@ -325,7 +325,7 @@ function system_view_general() {
'#description' => t('A file system path where the files will be stored. This directory has to exist and be writable by Drupal. If the download method is set to public this directory has to be relative to Drupal installation directory, and be accessible over the web. When download method is set to private this directory should not be accessible over the web. Changing this location after the site has been in use will cause problems so only change this setting on an existing site if you know what you are doing.')
);
$directory_temp = variable_get('file_directory_temp', FILE_DIRECTORY_TEMP);
$directory_temp = variable_get('file_directory_temp', ini_get('upload_tmp_dir'));
file_check_directory($directory_temp, FILE_CREATE_DIRECTORY, 'file_directory_temp');
$form['files']['file_directory_temp'] = array(
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment