Rumah  >  Artikel  >  php教程  >  PHP上传下载文件源码

PHP上传下载文件源码

WBOY
WBOYasal
2016-06-06 19:52:291487semak imbas

欢迎进入Linux社区论坛,与200万技术人员互动交流 >>进入 index.php !DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" html xmlns=".w3.org/1999/xhtml" head meta http-equiv="Content-Type

欢迎进入Linux社区论坛,与200万技术人员互动交流 >>进入

    index.php

   

   

   

   

   

filelist

   

   

   

    enctype="multipart/form-data">

   

   

   

   

   

   

   

   

   

    $dir = 'upload/';

    if(is_dir($dir)) {

    if ($dh = opendir($dir)) {

    while (($file = readdir($dh)) !== false) {

    if($file!="." && $file!="") {

    echo "

";

    }

    }

    closedir($dh);

    }

    }

    ?>

   

".$file."

   

   

    ---------------------------------------------------------------------------------------

    upload_file.php

    ----------------------------------------------------------------------------------------

   

    if ($_FILES["file"]["error"] > 0)

    {

    echo "Return Code: " . $_FILES["file"]["error"] . "
";

    }

    else

    {

    echo "Upload: " . $_FILES["file"]["name"] . "
";

    echo "Type: " . $_FILES["file"]["type"] . "
";

    echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb
";

    echo "Temp file: " . $_FILES["file"]["tmp_name"] . "
";

    if (file_exists("upload/" . $_FILES["file"]["name"]))

    {

    echo $_FILES["file"]["name"] . " already exists. ";

    }

    else

    {

    move_uploaded_file($_FILES["file"]["tmp_name"],

    "upload/" . $_FILES["file"]["name"]);

    echo "Stored in: " . "upload/" . $_FILES["file"]["name"];

    }

    }

    header('HTTP/1.1 301 Moved Permanently');

    header('Location:files.php');

    ?>

PHP上传下载文件源码

Kenyataan:
Kandungan artikel ini disumbangkan secara sukarela oleh netizen, dan hak cipta adalah milik pengarang asal. Laman web ini tidak memikul tanggungjawab undang-undang yang sepadan. Jika anda menemui sebarang kandungan yang disyaki plagiarisme atau pelanggaran, sila hubungi admin@php.cn
Artikel sebelumnya:优化PHP代码建议Artikel seterusnya:PHP5手动最简安装方法