增加一个bbsupload.c
#include "BBSLIB.inc"
void show_attach(){
DIR * dp;
int i;
char dir[1024];
struct dirent * entry;
struct stat statbuf;
sprintf(dir,"%s%s/%s",BASEDIR,currentuser.userid,getparm("utmpkey"));
if((dp=opendir(dir))==NULL){
printf("没有上传附件<br>\n");
return;
}
printf("<table border=0 cellpadding=0 cellspacing=0 width=100%>");
printf("<tr><td colspan=3>上传的附件有:<br>\n");
chdir(dir);
i=1;
while((entry=readdir(dp)) != NULL){
stat(entry->d_name,&statbuf);
if(strcmp(".",entry->d_name)==0 || strcmp("..",entry->d_name)==0)
continue;
if(S_ISDIR(statbuf.st_mode))
continue;
printf("<tr><td>附件%d:%20.20s <td>大小:%d字节<td><a href='bbsdelattach?file=%s'>删除该附件</a>\n",i,entry->d_name,file_size(entry->d_name));
i++;
}
printf("</table>");
chdir(BBSHOME);
closedir(dp);
}
int main() {
init_all();
if(!loginok) http_fatal("匆匆过客无法上传附件");
if(loginok)
modify_mode(u_info,POSTING);//add by everlove
printf("注意,bbs服务器资源宝贵,为节省空间,请勿上传过大的文件。请勿上传与版面无关的文件。<br>\n");
printf("目前单个上载文件大小限制为2M字节. <br>\n");
printf("请遵守国家法律,请勿上载非法资料和可能导致纠纷的资料。<br>\n");
printf("<form method=post action=/bbsupload.php enctype='multipart/form-data'>\n");
printf("<table>\n");
printf("<tr><td colspan=2>\n");
show_attach();
printf("<tr><td>上载附件: <td><input type=file name=up_file> ");
printf("<input type=hidden name=MAX_FILE_SIZE value=5000000>");
printf("<input type=hidden name=userid value='%s'>", currentuser.userid);
printf("<input type=submit name=submit value='开始上传'>");
printf("</table>\n");
printf("</form>");
}
--
FROM www.shuoshuo.net