日期:2014-05-16 浏览次数:20859 次
void quit(char* sMessage, int nCode)
{
cgiHeaderContentType("application/xml; charset=gb2312");
printf("<?xml version=\"1.0\" encoding=\"gb2312\"?>");
printf("<webresponse>");
printf("<code>%d</code>", nCode);
printf("<message>%s</message>", sMessage);
printf("</webresponse>");
}
int cgiMain()
{
int nSize = 0;
char sTmp[256];
struct stat sFileStat;
if(stat("/tmp/upload_12345", &sFileStat) < 0)
{
quit("file is not found in server!", 500);
return 0;
}
nSize = sFileStat.st_size;
snprintf(sTmp, sizeof(sTmp), "%d", nSize);
quit(sTmp, 200);
return 0;
}
var nRet = 0;
function getFileSize()
{
nRet = 0;
parent.$.ajax(
{
url: "/cgi-bin/abc/detectfile.cgi",
type: 'GET',
dataType: 'xml',
async: false,
timeout: 5000,
error: function()
{
nRet = -1;
},
success: function(sData)
{
if(parseInt(parent.$(sData).find("code").text()) != 200)
nRet = -2;
else
nRet = parseInt(parent.$(sData).find("message").text());
}
});
alert(nRet.toString());
}
function getFileSize()
{
nRet = 0;
parent.$.ajax(
{
cache:false,//==================
url: "/cgi-bin/abc/detectfile.cgi",
type: 'GET',
dataType: 'xml',
async: false,
timeout: 5000,
error: function()
{
nRet = -1;
},
success: function(sData)
{
if(parseInt(parent.$(sData).find("code").text()) != 200)
nRet = -2;
else
nRet = parseInt(parent.$(sData).find("message").text());
}
});
alert(nRet.toString());
}