PHP dynamic multi-file upload code sharing. The following code uploads a File :! DOCTYPEhtmlPUBLIC-W3CDTDXHTML1.0TransitionalENwww.w3.orgTRxhtml1DTDxhtml1-transitional.dtdhtmlxmlnswww.w everyone in through
Upload file code:
- >
- <Html Xmlns=Http://www.w3.org/1999/xhtml">
- <Head>
- <Meta Http-equiv="Content-Type" Content="Text/html; charset = gb2312" />
- <Title>Document Upload Title>
- Head>
- <Body>
- <Mce: script Language="Javascript">
- Function AddRow ()
- {
- VarENewRow=TblData. InsertRow ();
- For (varI=0; I<1; I ++)
- {
- VarENewCell=ENewRow. InsertCell ();
- ENewCell. innerHTML="";
- }
- }
-
- //--> Mce: script>
- <Form Name="Myform" Method="Post" Action="Uploadfile. php" Enctype="Multipart/form-data" >
- <Table Id="TblData" Width="400" Border="0">
-
-
-
- <Input Name="Postadd" Type="Hidden" Value=" PhpEcho"Http: // ". $ _ SERVER ['http _ host']. $ _ SERVER [" PHP_SELF "];?>"/>
- <Tr><Td>File upload list
- <Input Type="Button" Name="Addfile" Onclick="AddRow ()" Value="Add List" /> Td> Tr>
-
- <Tr><Td><Input Type="File" Name="Filelist []" Size="50" /> Td> Tr>
-
- Table>
- <Input Type="Submit" Name="Submitfile" Value="Submit file" />
- Form>
- Body>
- Html>
PHP code for submitting dynamic multi-file upload:
- Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
- <Html Xmlns=Http://www.w3.org/1999/xhtml">
- <Head>
- <Meta Http-equiv="Content-Type" Content="Text/html; charset = gb2312" />
- <Title>File upload result Title>
- Head>
- <Body>
- Php
- If ($ _ POST ["submitfile"]! = "")
- {
- $Path="./". Date ('ym ')."/";
- If (! Is_dir ($ Path) // create a Path
- {Mkdir ($ Path );}
- Echo"<P>";
- For ($I=0; $ I<Count($ Filelist); $ I ++)
- {// $ _ FILES ["filelist"] ["size"] [$ I] cannot be changed,
Because fileist is a two-dimensional array
- If ($ _ FILES ["filelist"] ["size"] [$ I]! = 0)
- {
- $File= $ Path. date ('ymdhm'). "_". $ _ FILES ["filelist"] ["name"] [$ I];
- If (move_uploaded_file ($ _ FILES ["filelist"] ["tmp_name"] [$ I], $ File ))
- {Echo "file type:". $ _ FILES ["filelist"]
["Type"] [$ I]. "". "File name :"
- . $ _ FILES ["filelist"] ["name"] [$ I]."<Br>";}
- Else
- {Echo "File name:". $ _ FILES ["filelist"] ["name"] [$ I]. "Upload failed Br>";}
- }
- }
- Echo" P><Br><A Href="$ Postadd" Mce_href="$ Postadd">Return A> P>";
- }
-
- ?>
- Body>
- Html>
The above is all PHP code for dynamic multi-file upload.
Upload File Code :! DOCTYPEhtmlPUBLIC "-// W3C // DTDXHTML1.0Transitional //" http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd "html xmlns =" http://www.w...