Prerequisites: Javascript, PHP (a few)/Perl (a few )!
Test environment: Windows2000 IIS5 PHP (Win98 PWS PHP3 failed, probably due to a configuration error)
Directory structure:
/Wwwroot/cgi-bin/fileup. php (File receipt)
/Wwwroot/www/test/phpfileup.htm (File submission)
/Wwwroot/www/test/tmp/(default directory)
Uploading files is simple and troublesome. The following is the submission page for uploading files. Using this page, you can generate not only 1000 Upload File boxes (actually any number of 0 ~ N), and you can specify their storage paths.
The file input box on the submit page is named: file0, file1,... file100,... fileN
The file path box on the submit page is named path0, path1,... path100,... pathN.
Because the page generation is very simple, I will not explain it here. Two functions are defined using javascript. check () is used to submit the page, and create () is used to generate a file upload box. If you have any better suggestions or have any questions, please Email: gearsoft@netease.com
Phpfileup.htm
--------------------------------------------------------
<Html>
<Head>
<Title> </title>
<Style>
. Lbtn {font-family: verdana; font-size: 10.5pt ;}
. Ist {font-family: verdana; font-size: 14.8px; size: 400}
</Style>
<Script LANGUAGE = "javascript">
Function check (){
Document. frm1.submit ();
Document. body. innerHTML = "Uploading Please wait! ";
}
Var I = 0;
Function create (){
Var sfrm = document. frm1.innerHTML;
Var icnt = cnt. value;
For (j = 0; j <icnt; j)
{
Sfrm = sfrm "SELECT file" I "<input type = file name = 'file" I "'class = ist> ";
Sfrm = sfrm "path: <input type = text name = 'path" I "'value = '../www/test/tmp/'class = ist> ";
Sfrm = sfrm "<br> ";
I;
}
Document. frm1.innerHTML = sfrm;
Document. frm1.cnt. value = I;
}
</Script>
</Head>
<Body class = lbtn onload = "document. frm1.cnt. value = cnt. value;">
Enter the number of files to upload: <input type = text name = cnt value = "10" class = ist onchange = "document. frm1.cnt. value = this. value;">
<Input type = button name = bt1 value = "generate Upload File Box" onclick = "create ();" class = lbtn>
<Input type = button name = bt1 value = "Upload" onclick = "check ();" class = lbtn>
<Input type = button name = bt1 value = "clear" onclick = "document. location. reload ();" class = lbtn>
<Form name = frm1 method = "post" Enctype = "multipart/form-data" action = ".../../cgi-bin/fileup. php">
<Input type = hidden name = cnt value = "20" class = ist>
</Form>
<Input type = button name = bt1 value = "Upload" onclick = "check ();" class = lbtn>
<Input type = button name = bt1 value = "clear" onclick = "document. location. reload ();" class = lbtn>
</Body>
</Html>
The following task is clear when the file submission page is generated: Save the submitted file content to the server.