chmod(buffer, HIDE_CHMOD);
if (filename != 0) chmod(filename, HIDE_CHMOD);
PUBLIC int LYUpload ARGS1(	char *, 	line){    char *method, *directory;    int method_number;    int count;    char *the_upload = 0;    char tmpbuf[LY_MAXPATH];    char buffer[LY_MAXPATH];    lynx_html_item_type *upload_command = 0;    FILE *fp;    char *the_command = 0;    /*     *	Use configured upload commands.     */    if((directory = (char *)strstr(line, "TO=")) == NULL)	goto failed;    *(directory - 1) = '\0';    /* go past "Directory=" */    directory += 3;    if((method = (char *)strstr(line, "UPLOAD=")) == NULL)	goto failed;    /*     *	Go past "Method=".     */    method += 7;    method_number = atoi(method);    for (count = 0, upload_command = uploaders; count < method_number;	count++, upload_command = upload_command->next)      ; /* null body */    /*     *	Parsed out the Method and the Location?     */    if (upload_command->command == NULL) {	HTAlert(gettext("ERROR! - upload command is misconfigured"));	goto failed;    }    /*     *	Care about the local name?     */    if (HTCountCommandArgs (upload_command->command)) {	/*	 *  Commands have the form "command %s [etc]"	 *  where %s is the filename.	 */	_statusline(FILENAME_PROMPT);retry:	*tmpbuf = '\0';	if (LYgetstr(tmpbuf, VISIBLE, sizeof(tmpbuf), NORECALL) < 0)	    goto cancelled;	if (*tmpbuf == '\0')	    goto cancelled;	if (strstr(tmpbuf, "../") != NULL) {	    HTAlert(gettext("Illegal redirection \"../\" found! Request ignored."));	    goto cancelled;	} else if (strchr(tmpbuf, '/') != NULL) {	    HTAlert(gettext("Illegal character \"/\" found! Request ignored."));	    goto cancelled;	} else if (tmpbuf[0] == '~') {	    HTAlert(gettext("Illegal redirection using \"~\" found! Request ignored."));	    goto cancelled;	}	sprintf(buffer, "%s/%s", directory, tmpbuf);#if HAVE_POPEN	if (LYIsPipeCommand(buffer)) {	    HTAlert(CANNOT_WRITE_TO_FILE);	    _statusline(NEW_FILENAME_PROMPT);	    goto retry;	}#endif	switch (LYValidateOutput(buffer)) {	case 'Y':	    break;	case 'N':	    goto retry;	default:	    goto cancelled;	}	/*	 *  See if we can write to it.	 */	CTRACE(tfp, "LYUpload: filename is %s", buffer);	if ((fp = fopen(buffer, "w")) != NULL) {	    fclose(fp);	    remove(buffer);	} else {	    HTAlert(CANNOT_WRITE_TO_FILE);	    _statusline(NEW_FILENAME_PROMPT);	    goto retry;	}	HTAddParam(&the_upload, upload_command->command, 1, buffer);	HTEndParam(&the_upload, upload_command->command, 1);    } else {			/* No substitution, no changes */	StrAllocCopy(the_upload, upload_command->command);    }    HTAddParam(&the_command, SUBDIR_COMMAND, 1, directory);    HTEndParam(&the_command, SUBDIR_COMMAND, 1);    StrAllocCat(the_command, the_upload);    CTRACE(tfp, "command: %s\n", the_command);    stop_curses();    LYSystem(the_command);    start_curses();    FREE(the_command);    FREE(the_upload);#ifdef UNIX    chmod(buffer, HIDE_CHMOD);#endif /* UNIX */    /* don't remove(file); */    return 1;failed:    HTAlert(gettext("Unable to upload file."));    return 0;cancelled:    HTInfoMsg(CANCELLING);    return 0;}