Multi-File Upload system full version _php tutorial

Source: Internet
Author: User
<?php
Multi-File upload system full version
Powerful, can arbitrarily control the number of uploaded files, whether to overwrite

Include (".. /include/common.inc ");
$title = "Upload program for multiple files";
Include (".. /include/header.inc ");

Define the number of files allowed to upload

Define ("Upload_no", 10);

Echo ("<p align= ' center ' ><font size= ' 4 ' color= ' #000080 ' > welcome! The <br> can be uploaded up to one time. Upload_no. " File <br> <HR> n ");
if ($REQUEST _method!= "POST") {
Echo ("<form enctype=" Multipart/form-data "Method=post>n");
Echo ("<input type=" hidden "name=" max_file_size "value=" 3000000 ">n");

for ($i =1; $i <=upload_no; $i + +) {
Echo ("<input type=file name=infile$i>");

if ($i%2==0)
Echo ("<br> N");
}

Echo ("<br> <br> <input type=" checkbox "Name=" Overload "Value=" on "> </font> <font color= ' #ff0000 ' > Overwrite files that already exist? </font> ");
Echo ("<br> <br> <input type=submit value= upload > </form> n");
}
else{
Handling uploads
$noinput = true;
for ($i =1; $noinput && ($i <=upload_no); $i + +) {
if (${"infile". $i}!= "None") $noinput = false;
}
if ($noinput) {
Echo ("<font size= ' 4 ' color= ' #000080 ') without the selected file, return to retry </font>");
Exit ();
}
Echo ("<p align= ' center ' ><font size= ' 4 ' color= ' #000080 ') your selected file has been successfully uploaded to the server's temp directory! </font> <br> ");
Echo ("<table border= ' 1 ' width= ' 84% ' height= '" bordercolorlight= ' "#008080 ' bordercolordark= ' #008080 '"
<tr>
<TD width= ' 14% ' bgcolor= ' #008000 ' height= ' ><font color= ' #FFFFFF ' and file number </font> </td>
<TD width= ' 52% ' bgcolor= ' #008000 ' height= ' "><font color= ' #FFFFFF ' > file name </font> </td>
<TD width= ' 34% ' bgcolor= ' #008000 ' height= ' "><font color= ' #FFFFFF ' > file size </font> </td>
</tr> ");

for ($i =1; $i <=upload_no; $i + +) {
$just =${"infile". $i. " _size "};
$fp _size[i] = $just;

if ($overload!=on) {
if (File_exists (Addslashes (dirname ($PATH _translated)). \upload\ ". ${" infile ". $i." _name "}))
echo "<font size= ' 4 ' color= ' #ff0000 ' > The file you uploaded <font color= ' #000000 '". ${"infile". $i. " _name "}." The </font> already exists and the copy of the file failed! </font> <br> ";
else{
if (${"infile". $i}!= "None" &© (${"infile". $i},addslashes (dirname ($PATH _translated)). " /upload/". ${" infile ". $i." _name "}) &&unlink (${" infile ". $i})) {
$str = ${"infile". $i. " _name "};
Echo ("<tr>
<TD width= ' 14% ' height= ' $i </td>
<TD width= ' 52% ' height= ' $str </td>
<TD width= ' 34% ' height= ' + $fp _size[i] </td>
</tr> ");
}
}
}
else{
if (${"infile". $i}!= "None" &© (${"infile". $i},addslashes (dirname ($PATH _translated)). " Upload ". ${" infile ". $i." _name "}) &&unlink (${" infile ". $i})) {
$str = ${"infile". $i. " _name "};
Echo ("<tr>
<TD width= ' 14% ' height= ' $i </td>
<TD width= ' 52% ' height= ' $str </td>
<TD width= ' 34% ' height= ' + $fp _size[i] </td>
</tr> ");
}
}

}
echo "</table>";
}

Include (".. /include/footer.inc ");

? >

http://www.bkjia.com/PHPjc/314186.html www.bkjia.com true http://www.bkjia.com/PHPjc/314186.html techarticle

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.