? common.inc.save ? file-save-data.patch Index: file.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/file.inc,v retrieving revision 1.88 diff -u -r1.88 file.inc --- file.inc 11 Dec 2006 16:45:17 -0000 1.88 +++ file.inc 27 Dec 2006 16:37:09 -0000 @@ -509,7 +509,8 @@ } /** - * Save a string to the specified destination. + * Save a string to the specified destination, or a temporary location if + * no destination was given. * * @param $data A string containing the contents of the file. * @param $dest A string containing the destination location. @@ -520,7 +521,7 @@ * * @return A string containing the resulting filename or 0 on error */ -function file_save_data($data, $dest, $replace = FILE_EXISTS_RENAME) { +function file_save_data($data, $dest = '', $replace = FILE_EXISTS_RENAME) { $temp = file_directory_temp(); $file = tempnam($temp, 'file'); if (!$fp = fopen($file, 'wb')) { @@ -530,8 +531,10 @@ fwrite($fp, $data); fclose($fp); - if (!file_move($file, $dest, $replace)) { - return 0; + if (!empty($dest)) { + if (!file_move($file, $dest, $replace)) { + return 0; + } } return $file;