• <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年6月>
            272829303112
            3456789
            10111213141516
            17181920212223
            24252627282930
            1234567

            常用鏈接

            留言簿(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 聶文龍 閱讀(545) 評論(0)  編輯 收藏 引用
            人妻无码αv中文字幕久久| 2021少妇久久久久久久久久| 日韩精品久久久肉伦网站| 久久精品国产亚洲AV久| 蜜臀久久99精品久久久久久小说| 国产成人精品久久一区二区三区| 亚洲国产成人久久精品动漫| 日韩十八禁一区二区久久| 亚洲va久久久久| 国产精品成人99久久久久91gav| 久久综合九色综合网站| 99久久国产热无码精品免费 | 亚洲精品无码成人片久久| 一本久久a久久精品综合香蕉| 久久亚洲国产精品123区| 久久66热人妻偷产精品9| 青青草原综合久久大伊人| 欧美久久天天综合香蕉伊| 久久精品亚洲乱码伦伦中文| 奇米影视7777久久精品| 久久综合成人网| 久久这里只有精品首页| 中文字幕久久波多野结衣av| 久久精品国产99国产精品| 色综合久久综精品| 国产99久久久国产精免费| 久久精品国产只有精品2020| 久久―日本道色综合久久| AAA级久久久精品无码区| 精品久久久久久久| 久久久久久亚洲精品无码| 久久人人爽人人爽人人片AV麻豆 | 国产精品va久久久久久久| 国产一区二区精品久久凹凸| 无码久久精品国产亚洲Av影片| 无码AV中文字幕久久专区| 久久亚洲国产中v天仙www| 久久笫一福利免费导航| 久久99精品久久久久久久不卡| 一级做a爰片久久毛片人呢| 无码八A片人妻少妇久久|