public static function move_uploaded_file($key, $destination = null, $data = null, $over_write = true) { $data = self::get_data($data); $data = $data[$key]->as_array(); if ($data['error'] == UPLOAD_ERR_OK) { if (!$destination) { $destination = moojon_paths::get_uploads_directory() . basename($data['name']); } self::attempt_mkdir(dirname($destination)); if ($over_write && is_file($destination)) { unlink($destination); } if (!is_file($destination)) { if (move_uploaded_file($data['tmp_name'], $destination)) { return $destination; } else { return false; } } else { $data['error'] = 'file exists'; } } throw new moojon_exception("Unable to upload file ({$destination}) (" . $data['error'] . ')'); return false; }