drupal 6 file_save_upload

Here is some code for uploading files to Drupal 6

file_save_upload($source, $validators = array(), $dest = FALSE, $replace = FILE_EXISTS_RENAME)

$source: A string specifying the name of the <b>upload field</b> to save.

$form['branded_logotyp'] = array('#type' => 'file'... => file_save_upload('branded_logotyp', ...

$validators: (optional) An associative array of callback functions used to validate the file. The keys are function names and the values arrays of callback parameters which will be passed in after the file object. The functions should return an array of error messages; an empty array indicates that the file passed validation. The functions will be called in the order specified.

$dest: A string containing the directory $source should be copied to. If this is not provided or is not writable, the temporary directory will be used.

function branding_admin_form() {
$form = array();
$form['#attributes'] = array('enctype' => "multipart/form-data");
$form['branded_logotyp'] = array(
'#type' => 'file',
'#title' => t('Logotyp:'),
'#size' => 60,
$form['submit'] = array(
'#type' => 'submit',
'#value' => 'Submit',
'#weight' => 10

branding_admin_form_submit(&$form, &$form_state) {
    if (
$file = file_save_upload('branded_logotyp', array('file_validate_is_image' => array()))) {
$parts = pathinfo($file->filename);
$filename = 'branded_logo'. '.' .$parts['extension'];
        if (
file_copy($file, $filename, FILE_EXISTS_REPLACE)) {
variable_set('zimonitor_branded_logotyp', $file->filepath);