PHP - 写入服务器文件夹被拒绝

I have done chmod -R 777 on the root folder, but I'm still unable to successfully
upload (thus, write) to the uploaded folder!

Do I also have to change the php.ini file?

//$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 ';
}

Output:

Moving file: camera.jpeg

to: /photoServerProject/uploaded/camera.jpeg

Location is NOT writeable

I was misunderstanding the difference between server and local disk directory structures. Namely, the root folders are different.

I'm surprised nobody brought up this issue.

Here's the solution:

<?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>";

?>

Try using

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

or

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

I was confusing the difference between paths on my local drive vs server paths. My root folder (localhosts) for server paths is different than my local directory structure.