On the web, people often ask me how to directly send files to files ??
Generally, wscript can be used by others. shell uses sendkeys for simulation, but it is useless. If you just don't like the file control, you can use the layer to make the file transparent and use the button to combine text. The two methods are as follows:
This is Method 2:
<Div style = "position: absolute; top: 11px; left:-71px; width: 150; filter: alpha (opacity = 0)">
<Input name = "file" type = "file" size = 33 onpropertychange = "A. value = This. Value">
</Div>
Method 1:
<Script language = JavaScript>
Function window. onload ()
{
Document. form1.t1. Focus ();
VaR wshshell = new activexobject ("wscript. Shell ");
Wshshell. sendkeys ("C: // test.txt"); // send the message to the text box
}
</SCRIPT>
This is not all. I have previously written a VB FTP upload file to make it a control for timed transfer.
Public declare function internetopen lib "wininet. dll" alias "internetopena "_
(Byval sagent as string, byval laccesstype as long, byval sproxyname as string ,_
Byval sproxybypass as string, byval lflags as long) as long
Public declare function internetconnect lib "wininet. dll" alias "internetconnecta "_
(Byval hinternetsession as long, byval sservername as string ,_
Byval nserverport as integer, byval susername as string ,_
Byval spassword as string, byval lservice as long ,_
Byval lflags as long, byval lcontext as long) as long
Public declare function ftpgetfile lib "wininet. dll" alias "ftpgetfilea "_
(Byval hftpsession as long, byval lpszremotefile as string ,_
Byval lpsznewfile as string, byval ffailifexists as Boolean ,_
Byval dwflagsandattributes as long, byval dwflags as long ,_
Byval dwcontext as long) as Boolean
Public declare function ftpputfile lib "wininet. dll" alias "ftpputfilea "_
(Byval hftpsession as long, byval lpszlocalfile as string ,_
Byval lpszremotefile as string, byval dwflags as long ,_
Byval dwcontext as long) as Boolean
Public declare function ftpdeletefile lib "wininet. dll" alias "ftpdeletefilea "_
(Byval hftpsession as long, byval lpszfilename as string) as Boolean
Public declare function ftprenamefile lib "wininet. dll" alias "ftprenamefilea "_
(Byval hftpsession as long, byval lpszexsiting as string, byval lpsznew as string) as Boolean
Public declare function internetclosehandle lib "wininet. dll" (byval hinet as long) as integer
Private sub timer1_timer ()
Lnginet = internetopen (vbnullstring, internet_open_type_preconfig ,_
Vbnullstring, vbnullstring, 0 &)
If lnginet then
Lnginetconn = internetconnect (lnginet, "210.51.180.101", 0 ,_
"Username", "password", 1, 0, 0)
If lnginetconn then
Blnrc = ftpputfile (lnginetconn, "your specific uploaded stuff", "FTP folder of the Website", 0, 0, 1, 0)
If blnrc then
Msgbox "Download OK !!! "
End if
Internetclosehandle lnginetconn
Internetclosehandle lnginet
Else
A = 1
Doevents
End if
Else
A = 2
Doevents
End if
End sub
Of course, this is not final, because others must upload HTTP after all.
After research, we found that a good solution is to use the httpsendrequest function, which can be directly uploaded using the HTTP protocol. The only problem is that the client must allow you to register
Bool usehttpsendreqex (hinternet hrequest, DWORD dwpostsize)
{
Internet_buffers Bufferin;
DWORD dwbyteswritten;
Int N;
Byte pbuffer [1024];
Bool Bret;
Bufferin. dwstructsize = sizeof (internet_buffers );
// Must be set or error will occur
Bufferin. Next = NULL;
Bufferin. lpcszheader = NULL;
Bufferin. dwheaderslength = 0;
Bufferin. dwheaderstotal = 0;
Bufferin. lpvbuffer = NULL;
Bufferin. dwbufferlength = 0;
Bufferin. dwbuffertotal = dwpostsize;
// This is the only member used other than dwstructsize
Bufferin. dwoffsetlow = 0;
Bufferin. dwoffsethigh = 0;
If (! Httpsendrequestex (hrequest, & Bufferin, null, 0, 0 ))
{
Printf ("error on httpsendrequestex % d/N", getlasterror ());
Return false;
}
Fillmemory (pbuffer, 1024, 'D'); // fill buffer with data
Bret = true;
For (n = 1; n <= (INT) dwpostsize/1024 & Bret; n ++)
{
If (Bret = internetwritefile (hrequest, pbuffer, 1024, & dwbyteswritten ))
Printf ("/R % d bytes sent.", N * 1024 );
}
If (! Bret)
{
Printf ("/nerror on internetwritefile % lu/N", getlasterror ());
Return false;
}
If (! Httpendrequest (hrequest, null, 0, 0 ))
{
Printf ("error on httpendrequest % lu/N", getlasterror ());
Return false;
}
Return true;
}
This is written in VC. The truth is the same. You can find the prototype of httpsendrequest on msdn. The difficulty of the above program is to split the file for ASP to receive