如何在 Windows 中指定文件夹的路径


How to specify path for the folder in Windows

我有一个表单,允许用户将文件上传到服务器,但我不知道如何在服务器中为该文件夹编写正确的路径,我希望文件存储在其中,以及如何获取特定文件的路径以供以后下载。

服务器中的路径:

/public_html/upload_files

我得到的错误:

警告: move_uploaded_file(upload_files/project_guidelines.pdf): 无法打开流:中没有此类文件或目录 D:''sites''dwts.com''public_html''website''creat.php 在第 50 行 警告: move_uploaded_file(): 无法将"C:''Windows''Temp''php14AC.tmp"移动到 "upload_files/project_guidelines.pdf" in D:''sites''dwts.com''public_html''website''create.php 在第 50 行 错误 上传文件

法典:

$len = count($_FILES['Attachment']['name']);
for($i = 0; $i < $len; $i++) {
$uploadDir = 'upload_files/';
$fileName = $_FILES['Attachment']['name'][$i];
$tmpName = $_FILES['Attachment']['tmp_name'][$i];
$fileSize = $_FILES['Attachment']['size'][$i];
$fileType = $_FILES['Attachment']['type'][$i];
$filePath = $uploadDir . basename($_FILES['Attachment']['name'][$i]);
$result = move_uploaded_file($tmpName,$filePath);
if (!$result) {
    echo "Error uploading file";
    exit;
}
$uploadDir = 'upload_files/';

驱动器在哪里? 它的窗口,所以它需要一个驱动器:

$uploadDir = 'c:/upload_files/';

你不能给move_uploaded_file的第二个参数一个部分位置......它需要一个完整的路径。