Home  >  Article  >  Backend Development  >  PHP multiple file upload and download sample code

PHP multiple file upload and download sample code

PHP中文网
PHP中文网Original
2017-03-18 09:33:24891browse

php moreFile uploadDownload sample code



    
    index_uploads






index_uploads.php

";
    print_r($_FILES);
    echo "
"; $count = count($_FILES['file']['name']); for ($i = 0; $i < $count; $i++) { $tmpfile = $_FILES['file']['tmp_name'][$i]; $filefix = array_pop(explode(".", $_FILES['file']['name'][$i])); $dstfile = "uploads/files/".time()."_".mt_rand().".".$filefix; if (move_uploaded_file($tmpfile, $dstfile)) { echo ""; } else { echo ""; } }

uploads.php

";
                    echo "";
                    echo "Download";
                    echo "";
                }
            }
        }
    } 
    echo "

图片下载|图片上传

"; echo ""; listdir($dirname); echo "
";

listdir.php

download.php

Core download:

header("content-type:application/octet-stream");
header("content-disposition:attachment;filename={$imgfile}");
header("content-length:{$imgsize}");
readfile($path);
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn