<span style="font: 14px/21px 微軟雅黑; text-align: left; color: rgb(0, 0, 0); text-transform: none; text-indent: 0px; letter-spacing: normal; word-spacing: 0px; float: none; display: inline !important; white-space: normal; background-color: rgb(255, 255, 255); -webkit-text-stroke-width: 0px;">提交的方式有兩種get和post</span><div style="font: 14px/21px 微軟雅黑; text-align: left; color: rgb(0, 0, 0); text-transform: none; text-indent: 0px; letter-spacing: normal; word-spacing: 0px; white-space: normal; background-color: rgb(255, 255, 255); -webkit-text-stroke-width: 0px;">get:</div><div style="font: 14px/21px 微軟雅黑; text-align: left; color: rgb(0, 0, 0); text-transform: none; text-indent: 0px; letter-spacing: normal; word-spacing: 0px; white-space: normal; background-color: rgb(255, 255, 255); -webkit-text-stroke-width: 0px;"> 這種傳送方式所傳輸的內容有長度限制,一般在一百多字節以內。但是它所傳送的 特殊字符 不需要的轉換。</div><div style="font: 14px/21px 微軟雅黑; text-align: left; color: rgb(0, 0, 0); text-transform: none; text-indent: 0px; letter-spacing: normal; word-spacing: 0px; white-space: normal; background-color: rgb(255, 255, 255); -webkit-text-stroke-width: 0px;"><br style="background-color: inherit;" /></div><div style="font: 14px/21px 微軟雅黑; text-align: left; color: rgb(0, 0, 0); text-transform: none; text-indent: 0px; letter-spacing: normal; word-spacing: 0px; white-space: normal; background-color: rgb(255, 255, 255); -webkit-text-stroke-width: 0px;">post:</div><div style="font: 14px/21px 微軟雅黑; text-align: left; color: rgb(0, 0, 0); text-transform: none; text-indent: 0px; letter-spacing: normal; word-spacing: 0px; white-space: normal; background-color: rgb(255, 255, 255); -webkit-text-stroke-width: 0px;"> 這種傳送方式的內容可以比較大,可以大於2048字節,傳送文件也是用這種方式,傳送文件需要在form裏添加</div><div style="font: 14px/21px 微軟雅黑; text-align: left; color: rgb(0, 0, 0); text-transform: none; text-indent: 0px; letter-spacing: normal; word-spacing: 0px; white-space: normal; background-color: rgb(255, 255, 255); -webkit-text-stroke-width: 0px;">enctype="multipart/form-data"。</div><div style="font: 14px/21px 微軟雅黑; text-align: left; color: rgb(0, 0, 0); text-transform: none; text-indent: 0px; letter-spacing: normal; word-spacing: 0px; white-space: normal; background-color: rgb(255, 255, 255); -webkit-text-stroke-width: 0px;"> post不加文件傳輸方式的話,傳送的內容和get的一樣,不過特殊字符就需要自己手動轉換如:</div><blockquote style="font: 14px/21px 微軟雅黑; margin: 0px 0px 0px 40px; padding: 0px; border: currentColor; border-image: none; text-align: left; color: rgb(0, 0, 0); text-transform: none; text-indent: 0px; letter-spacing: normal; word-spacing: 0px; white-space: normal; background-color: rgb(255, 255, 255); -webkit-text-stroke-width: 0px;"><div style="background-color: inherit;">1. + URL 中+號表示空格 %2B</div><div style="background-color: inherit;">2. 空格 URL中的空格可以用+號或者編碼 %20</div><div style="background-color: inherit;">3. / 分隔目錄和子目錄 %2F</div><div style="background-color: inherit;">4. ? 分隔實際的 URL 和參數 %3F</div><div style="background-color: inherit;">5. % 指定特殊字符 %25</div><div style="background-color: inherit;">6. # 表示書籤 %23</div><div style="background-color: inherit;">7. & URL 中指定的參數間的分隔符 %26</div><div style="background-color: inherit;">8. = URL 中指定參數的值 %3D</div></blockquote><span style="font: 14px/21px 微軟雅黑; text-align: left; color: rgb(0, 0, 0); text-transform: none; text-indent: 0px; letter-spacing: normal; word-spacing: 0px; float: none; display: inline !important; white-space: normal; background-color: rgb(255, 255, 255); -webkit-text-stroke-width: 0px;"> 這些特殊字符以經過提交時防止出錯轉換的,轉換的規則是“%”+“特殊字符的ascii碼的十六進制”,</span><div style="font: 14px/21px 微軟雅黑; text-align: left; color: rgb(0, 0, 0); text-transform: none; text-indent: 0px; letter-spacing: normal; word-spacing: 0px; white-space: normal; background-color: rgb(255, 255, 255); -webkit-text-stroke-width: 0px;">轉換的函數可以參考:</div>
void WebTransUrl(const char *apcSrc, char* apcDst, int aiSize)
{
int i = 0;
int lnDstId = 0;
while((i < aiSize - 1) && apcSrc[i])
{
if ('+' == apcSrc[i])
{
apcDst[lnDstId] = ' ';
}
else if ('%' == apcSrc[i])
{
apcDst[lnDstId] = (((unsigned char)apcSrc[i + 1] - '0') << 4 ) | ((unsigned char)apcSrc[i + 2] - '0');
i += 2;
}
else
{
apcDst[lnDstId] = apcSrc[i];
}
++i;
++lnDstId;
}
apcDst[lnDstId] = 0;
}