The file is loaded and displays at the end that everything went well, but the file does not appear in the folder

Rights Exposed

sudo chmod -R 777 /Applications/XAMPP/ {"Message":"The file 374.png has been uploaded.","Status":"OK"} 

Index.php

 <form enctype="multipart/form-data" action="upload.php" method="POST"> <input type="hidden" name="MAX_FILE_SIZE" value="100000" /> Choose a file to upload: <input name="uploadedfile" type="file" /><br /> <input type="submit" value="Upload File" /> </form> 

Upload.php

 <?php $target_path = dirname(getcwd()).'/img/'; $target_path = $target_path . basename( $_FILES['uploadedfile']['name']); if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) { echo json_encode([ "Message" => "The file ". basename($_FILES["uploadedfile"]["name"]). " has been uploaded.", "Status" => "OK" ]); } else{ echo json_encode([ "Message" => "Sorry, there was an error uploading your file.", "Status" => "Error" ]); } ?> 

    1 answer 1

    Found a mistake! Wrong path specified.

    changed - $ target_path = dirname (getcwd ()). '/ img /';

    on - $ target_path = dirname ( FILE ). '/ img /';