Index: /branches/rel_apv_10_7/usr/click/bin/backend/sys_cmd.c
===================================================================
--- /branches/rel_apv_10_7/usr/click/bin/backend/sys_cmd.c	(revision 39230)
+++ /branches/rel_apv_10_7/usr/click/bin/backend/sys_cmd.c	(working copy)
@@ -149,6 +149,7 @@
 #define SFTP_PATH		"/usr/bin/sftp"
 #define SSH_PATH		"/ca/bin/ssh"
 #define CP_PATH			"/bin/cp"
+#define RM_PATH			"/bin/rm"
 #define KILL_ALL_PATH	"/usr/bin/killall -SIGUSR2" /*signal the process with SIGUSR2*/
 #define SSH_OPTIONS		"-H -o \"StrictHostKeyChecking=no\""
 #define FETCH_PATH		"/usr/bin/fetch"
@@ -180,6 +181,7 @@
 #define new_version     	"/var/spool/upgrade/new.version"
 #define UPGRADE_DIR		"/var/spool/upgrade"
 #define PACKAGE_DIR         "/var/crash/package"
+#define TMP_WEBUI_DIR         "/tmp/webui_upload/"
 
 /* 
  * Following defines are in the 
@@ -2404,6 +2406,19 @@
 	return 0;
 }
 
+// Returns true if the string is a URL
+int is_url(const char *path) {
+	return (strncmp(path, "http://", 7) == 0 ||
+			strncmp(path, "https://", 8) == 0 ||
+			strncmp(path, "ftp://", 6) == 0 ||
+			strncmp(path, "sftp://", 7) == 0);
+}
+
+int dir_exists(const char *path) {
+	struct stat st;
+	return (stat(path, &st) == 0);
+}
+
 /*
 	Validate the URL, print a warning message if everything passes call
 	the perl update script
@@ -2571,6 +2586,15 @@
 	close(fd);
 	more_off();
 
+	if (is_url(url) && dir_exists(TMP_WEBUI_DIR)) {
+		snprintf(cmd, BUFSIZ, "%s %s %s", RM_PATH, "-rf", TMP_WEBUI_DIR);
+		int rc = system(cmd);
+		if (rc != 0) {
+			printf("failed to remove files from %s\n", TMP_WEBUI_DIR);
+			goto error;
+		}
+	}
+
 	if(strstr(url, "sftp://") != NULL) {
 		if(through_sftp_download_file(url, tmp) == -1) {
 			printf("Package download failed.\n");
Index: /branches/rel_apv_10_7/usr/click/tools/click_upgrade.pl
===================================================================
--- /branches/rel_apv_10_7/usr/click/tools/click_upgrade.pl	(revision 39230)
+++ /branches/rel_apv_10_7/usr/click/tools/click_upgrade.pl	(working copy)
@@ -169,9 +169,23 @@
 }
 
 sub get_additional_size {
-    my $cmd = "$du -sm /caupgrade/ca /caupgrade/home /caupgrade/root /caupgrade/media /caupgrade/mnt /caupgrade/opt /caupgrade/srv /caupgrade/sys /caupgrade/lib /caupgrade/lib64 /caupgrade/bin /caupgrade/sbin /caupgrade/usr /caupgrade/etc | $awk '{sum += \$1} END {print sum}'";
-    my $size = `$cmd`;
-    return ($size =~ /^\d+$/) ? $size : 0;
+	my $webui_path = "/caupgrade/tmp/webui_upload";
+
+	my @dirs = (
+		"/caupgrade/ca", "/caupgrade/home", "/caupgrade/root", "/caupgrade/media",
+		"/caupgrade/mnt", "/caupgrade/opt", "/caupgrade/srv", "/caupgrade/sys",
+		"/caupgrade/lib", "/caupgrade/lib64", "/caupgrade/bin", "/caupgrade/sbin",
+		"/caupgrade/usr", "/caupgrade/etc"
+	);
+
+	if (-d $webui_path) {
+		push @dirs, $webui_path;
+	}
+
+	my $cmd = "$du -sm @dirs | $awk '{sum += \$1} END {print sum}'";
+	my $size = `$cmd`;
+
+	return ($size =~ /^\d+$/) ? $size : 0;
 }
 
 my $remaining_size = `$df -m $up_dir|$grep "^/" |$awk '{printf \$4}'`;
Index: /branches/rel_apv_10_7/usr/click/tools/pre_upgrade_hooks.sh
===================================================================
--- /branches/rel_apv_10_7/usr/click/tools/pre_upgrade_hooks.sh	(revision 39230)
+++ /branches/rel_apv_10_7/usr/click/tools/pre_upgrade_hooks.sh	(working copy)
@@ -34,6 +34,11 @@
 	rm -rf /caupgrade/usr/*
 	rm -rf /caupgrade/etc/*
 
+	# Only clear /caupgrade/tmp/webui_upload if it exists
+	if [ -d /caupgrade/tmp/webui_upload ]; then
+		rm -rf /caupgrade/tmp/webui_upload/*
+	fi
+
 	#the log
 	echo "clear caupgrade files success." >> /var/spool/upgrade/upgrade.log
 }
