⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 uploads.csp

📁 eybuild-x86-arm920t-2.6.7.tar 很好的嵌入式WEB开发环境
💻 CSP
字号:
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=gb2312">
<title>eyBuild Demo - Upload Server</title>
<link href="/style.css" rel=stylesheet type=text/css>
</head>
<body>
<h3>上传结果:</h3>
<%
//list includes files
@ include <ebpost.h>
@ifdef WIN32
@   include <io.h>
@   include <direct.h>
@   define mkdir(n, m)	mkdir(n)
@else
@   include <sys/stat.h>
@   include <unistd.h>
@endif
%>

<%
{{
    POST_PARAM *      p_param = NULL;
    THIS_POST *       p_post;
    int               i, filecount;
    BOOL              force_remove = FALSE;
    char *            destdir = NULL;
    char *            default_dir= "./";
    char              errmsg[256] = "";
    int               max_post_size = 200 * (1024*1024); /* 100M */

    /* create post parameters:
     *
     * extern POST_PARAM * createPostParam
     *     (
     *     int             max_post_size,      /@ max post size @/
     *     int             file_max_size,      /@ max size each file @/
     *     int             max_file_number,    /@ max file may uploads @/
     *     char *          upload_tmp_dir,     /@ where to store temp @/
     *     int             options             /@ other options @/
     *     );
     */
     
    /* has no enough memory */
    if (NULL == (p_param=createPostParam(max_post_size, max_post_size, 3, NULL, 0)))
    {
        page_exit(ERROR);
    }
    
    /* done post */
    if (NULL == (p_post=dopost(p_param, errmsg)) )
    {
        print("上传错误: <b>%s</b>\n", errmsg);
    } 
    else 
    {
    
        /* set where to upload to */
        destdir = getPostItemValue(p_post, "upload_to_dir");
        if (NULL == destdir || '\0' == *destdir)
            destdir = default_dir;
        chmod(destdir,0777);
        /* value is "checked" */
        if (NULL != getPostItemValue(p_post, "force_remove"))
        {
            print("<p><font color=red>要求强制删除服务器上传目录中已存在的文件</font></p>\n");
            force_remove = TRUE;
        }
    
        /* get file number uploads */
        filecount = getPostFileCount(p_post);
        if (filecount <= 0)
            print("<p><font color=red>没有要上传的文件!</font></p>");
%>

<%
        /* create a director for file */
        mkdir (destdir,0777);
        for (i=0; i < filecount; i++)
        {
            int          ret;
            char         filename[512] = "";
            char *       message;
            char *       p = destdir + strlen(destdir);
            
            /* remove old file */
            p > destdir ? p--: 0;
            sprintf(filename, "%s%s%s", 
                    destdir, 
                    ('/'==*p || '\\'==*p) ? "" : "/", 
                    get_filename(getPostSrcFileName(p_post, i)));
            if (force_remove)
                ret=unlink(filename);
            
            /* move file */
            if (0 != (ret=movePostFile(p_post, i, destdir)))
                message = "<font color=red>文件已经存在!</font>";
            else
                message = "文件上传成功!";
           
            /* change file R/W mode */
            chmod(filename, 0664);
%>
<table>
<tr>
    <td align=right>文件 <% print("%d", i+1); %>:</td>
    <td>
    <table>
        <tr><td>源地址:</td>
            <td><% =getPostSrcFileName(p_post, i); %></td>
        <tr><td>存贮到: </td>
            <td><% =destdir %></td>
        <tr><td>状态: </td>
            <td><% =message %></td>
    </table>
    </td>
</tr>
</table>
<%      } /* for */

        if (p_post)
            distoryPost(p_post, TRUE);
    }
}}
%>
<p>
<a href="uploadc.csp?path=<% =urlEncode(G("path")) %>">继续上传文件<a> | 
<a href="list.csp?path=<% =urlEncode(G("path")) %>">返回到目录列表<a>
</body>
</html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -