首页 >php教程 >PHP源码 >PHP 文件上传代码

PHP 文件上传代码

PHP中文网
PHP中文网原创
2016-05-25 17:13:371016浏览

[PHP]代码 

<?php
// basic php file upload example
// http://www.php.cn/

if ($_POST[&#39;upload&#39;]){ //process uploaded file
    $uploadDir = &#39;/domains/path-com/path/www_root/_crop/full-&#39;; //file upload path
    $uploadFile = $uploadDir . $_FILES[&#39;uploadfile&#39;][&#39;name&#39;];
    echo "<pre class="brush:php;toolbar:false">";
    if (move_uploaded_file($_FILES[&#39;uploadfile&#39;][&#39;tmp_name&#39;], $uploadFile) )
    {
        echo "File is valid, and was successfully uploaded. ";
        echo "Here&#39;s some more debugging info:\n";
    }
    else
    {
        echo "ERROR!  Here&#39;s some debugging info:\n";
        echo "remember to check valid path, max filesize\n";
		echo "$-POST-upload: ".$_POST[&#39;upload&#39;];
    }
    echo "
"; } else { //display upload form ?>


                   

                   

声明:
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn