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

PHP 文件上传代码

PHP中文网
PHP中文网Original
2016-05-25 17:13:371023browse

[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 ?>


                   

                   

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