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

PHP 文件上传代码

PHP中文网
Release: 2016-05-25 17:13:37
Original
1025 people have browsed it

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


Copy after login

                   

                   

Related labels:
php
source:php.cn
Statement of this Website
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
Latest Articles by Author
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template