/index.html :
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <title>Document</title> </head> <body> <form method="post" action="upload.php" enctype="multipart/form-data"> <label for="file-label">File : </label> <input type="file" name="myfile"> <h3> File Upload Handler </h3> <p>/upload.php :<br> </p> <pre class="brush:php;toolbar:false"><?php $tempFile = $_FILES['myfile']['tmp_name']; $fileName = $_FILES['myfile']['name']; $fileDestination = __DIR__."/uploads/".$fileName; copy($tempFile, $fileDestination); unlink($tempFile);
注意:
必须事先创建 /uploads 文件夹。
以上是php 中的简单文件上传的详细内容。更多信息请关注PHP中文网其他相关文章!