0

我已经完成chmod -R 777了根文件夹,但我仍然无法成功
上传(因此,写入)到上传的文件夹!

我是否还必须更改 php.ini 文件?

//$target_path = "http://localhost/photoServerProject/uploaded";
$target_path = "/photoServerProject/uploaded";
$fname = $_FILES["file"]["name"];
$upload_location = $target_path.'/'.$fname;

move_uploaded_file($_FILES["file"]["tmp_name"], $upload_location);

echo 'Moving file: ' . $fname . '</br></br>to: ' . $upload_location;
//echo "<img src=$upload_location>";

if(is_writeable($upload_location)){
    echo '</br></br>Location <strong>is</strong> writeable ';
} else {
    echo '</br></br>Location <strong>is NOT</strong> writeable ';
}

输出:

移动文件:camera.jpeg

到:/photoServerProject/uploaded/camera.jpeg

位置不可

4

3 回答 3

0

尝试使用

$targetPath= $_SERVER['DOCUMENT_ROOT'] . "photoServerProject/uploaded"

或者

$targetPath= $_SERVER['DOCUMENT_ROOT'] . "/photoServerProject/uploaded"
于 2013-09-27T22:08:53.697 回答
0

我混淆了本地驱动器上的路径与服务器路径之间的区别。我的服务器路径的根文件夹(localhosts)与我的本地目录结构不同。

于 2013-09-27T23:07:08.433 回答
0

我误解了服务器和本地磁盘目录结构之间的区别。即,根文件夹不同。

我很惊讶没有人提出这个问题。

这是解决方案:

<?php

    $local_target = "~/webdev/photoServerProject/uploaded/";
    $server_target = $_server['DOCUMENT_ROOT'] . "/photoServerProject/uploaded/";

    $fname = $_FILES["file"]["name"];

    $local_file_location = $local_target.$fname;
    $server_file_location = $server_target.$fname;

    move_uploaded_file($_FILES["file"]["tmp_name"], $local_file_location);

    echo 'Moving file: ' . $fname . '</br></br>to local path: ' . $local_file_location;
    echo '</br></br> But on the server it resides in : ' . $server_file_location;
    echo '</br></br> See?';
    echo "</br></br> <img src=$server_file_location>";

?>
于 2013-09-27T23:16:38.447 回答