PHP multiple File Upload code three

Source: Internet
Author: User
Tags file upload

<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<meta http-equiv= "Content-type" content= "text/html; charset=gb2312 "/>
<title> display files in folder </title>

<body>
<?php
$sort _file=array ();
$FILEFJ =array ();
Define (' FILEPATH ', '. /filehandle/uploadfile/');
$sortlist =trim ($_get["sort"]);
$dir =opendir (FILEPATH);
echo ' File upload location: '. FILEPATH. ' <br/> ';
echo ' file list: '. ' <ul> ';

if ($sortlist = = ' filetype ') {
while (($file =readdir ($dir))!== false) {
if ($file!= "." && $file!= "...") {
$file =basename ($file);
$sort _file[]= $file;
}
}

foreach ($sort _file as $key => $var) {
$FILEFJ []=explode ('. ', $var);
}

Usort ($FILEFJ, ' compare ');

foreach ($filefj as $key => $val) {
$combinationfile =implode ('. ', $val);
Echo ' <li> '. $combinationfile. ' </li> ';
}
}else{
while (($file =readdir ($dir))!== false) {
if ($file!= "." && $file!= "...") {
$file =basename ($file);
Echo ' <li> ' $file. $file _size. ' </li> ';
}
}
}
Echo ' </ul> ';
Closedir ($dir);
Echo ' </br> ';
Echo ' <a href= "Index.php?sort=filetype" > sorted by File type </a>&nbsp;&nbsp;&nbsp;<a href= " index.php "> sorted by normal file </a>&nbsp;&nbsp;&nbsp;<a href=" upfile.html "> Continue uploading Files </a> ';

function Compare ($x, $y) {
if ($x [1]== $y [1])
return 0;
else if ($x [1]< $y [1])
return-1;
else return 1;
}
?>

</body>
File effect will not say, I try to know.

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.