• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            隨筆 - 298  文章 - 377  trackbacks - 0
            <2007年8月>
            2930311234
            567891011
            12131415161718
            19202122232425
            2627282930311
            2345678

            常用鏈接

            留言簿(34)

            隨筆分類

            隨筆檔案

            文章檔案

            相冊

            收藏夾

            搜索

            •  

            最新評論

            閱讀排行榜

            評論排行榜

              #include <windows.h>
              #include 
            <wininet.h>
              #include 
            <iostream>


              
            #define ERROR_OPEN_FILE       10
              
            #define ERROR_MEMORY          11
              
            #define ERROR_SIZE            12
              
            #define ERROR_INTERNET_OPEN   13
              
            #define ERROR_INTERNET_CONN   14
              
            #define ERROR_INTERNET_REQ    15
              
            #define ERROR_INTERNET_SEND   16

              
            using namespace std;

              
            int main()
              {
                 
            // Local variables
                 static char *filename   = "test.txt";   //Filename to be loaded
                 static char *type       = "image/jpg";
                 
            static char boundary[]  = "pippo";            //Header boundary
                 static char nameForm[]  = "uploadedfile";     //Input form name
                 static char iaddr[]     = "localhost";        //IP address
                 static char url[]       = "test.php";         //URL

                 
            char hdrs[255];                  //Headers
                 char * buffer;                   //Buffer containing file + headers
                 char * content;                  //Buffer containing file
                 FILE * pFile;                    //File pointer
                 long lSize;                      //File size
                 size_t result;                   


                 
            // Open file
                 pFile = fopen ( filename , "rb" );
                 
            if (pFile==NULL) return ERROR_OPEN_FILE;

                 
            // obtain file size:
                 fseek (pFile , 0 , SEEK_END);
                 lSize 
            = ftell (pFile);
                 rewind (pFile);

                 
            // allocate memory to contain the whole file:
                 content = (char*) malloc (sizeof(char)*lSize);
                 
            if (content == NULL) return ERROR_MEMORY;

                 
            // copy the file into the buffer:
                 result = fread (content,1,lSize,pFile);
                 
            if (result != lSize) return ERROR_SIZE;

                 
            // terminate
                 fclose (pFile);

                 
            //allocate memory to contain the whole file + HEADER
                 buffer = (char*) malloc (sizeof(char)*lSize + 2048);

                 
            //print header
                 sprintf(hdrs,"Content-Type: multipart/form-data; boundary=%s",boundary);
                 sprintf(buffer,
            "--%s\r\nContent-Disposition: form-data; name=\"%s\"; filename=\"%s\"\r\n",boundary,nameForm,filename);
                 sprintf(buffer,
            "%sContent-Type: %s\r\n\r\n",buffer,type);
                 sprintf(buffer,
            "%s%s\r\n",buffer,content);
                 sprintf(buffer,
            "%s--%s--\r\n",buffer,boundary);

                 
            //Open internet connection
                 HINTERNET hSession = InternetOpen("WinSock",INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0);
                 
            if(hSession==NULL) return ERROR_INTERNET_OPEN;

                 HINTERNET hConnect 
            = InternetConnect(hSession, iaddr,INTERNET_DEFAULT_HTTP_PORT, NULL, NULL, INTERNET_SERVICE_HTTP, 01);
                 
            if(hConnect==NULL) return ERROR_INTERNET_CONN;

                 HINTERNET hRequest 
            = HttpOpenRequest(hConnect, (const char*)"POST",url, NULL, NULL, (const char**)"*/*\0"01);
                 
            if(hRequest==NULL) return ERROR_INTERNET_REQ;

                 BOOL sent
            = HttpSendRequest(hRequest, hdrs, strlen(hdrs), buffer, strlen(buffer));
                 
            if(!sent) return ERROR_INTERNET_SEND;

                 
            //close any valid internet-handles
                 InternetCloseHandle(hSession);
                 InternetCloseHandle(hConnect);
                 InternetCloseHandle(hRequest);

                 
            return 0;
              }
            posted on 2017-06-30 15:23 聶文龍 閱讀(549) 評論(0)  編輯 收藏 引用
            久久国产精品无码HDAV | 久久无码高潮喷水| 伊人久久精品无码av一区| 久久无码人妻一区二区三区| 久久久久夜夜夜精品国产| 久久婷婷色综合一区二区| 久久亚洲精品中文字幕| 久久精品无码免费不卡| aaa级精品久久久国产片| 一本久道久久综合狠狠躁AV| 久久精品一本到99热免费| 一本色道久久88综合日韩精品 | 国产综合久久久久| 内射无码专区久久亚洲| 久久亚洲欧美日本精品| 日韩精品久久久久久久电影蜜臀 | 亚洲精品美女久久久久99小说 | 国产亚洲美女精品久久久2020| 亚洲综合久久综合激情久久| 日日噜噜夜夜狠狠久久丁香五月| 国产福利电影一区二区三区久久久久成人精品综合 | 久久福利片| 大美女久久久久久j久久| 亚洲AV日韩精品久久久久久| 午夜精品久久久久久久无码| 99久久成人18免费网站| 久久精品无码专区免费东京热| 午夜精品久久久久久影视riav| 久久激情五月丁香伊人| 久久国产精品国语对白| 久久久久久无码国产精品中文字幕 | 天堂无码久久综合东京热| 久久久久久亚洲精品不卡| 国产一区二区精品久久凹凸 | 久久青青草原综合伊人| 精品久久777| 久久综合久久久| 精品免费久久久久国产一区| 丁香五月综合久久激情| 色诱久久av| 亚洲国产欧美国产综合久久|