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

PHP 文件上传代码

PHP中文网
PHP中文网asal
2016-05-25 17:13:371017semak imbas

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


                   

                   

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