Uploading a file to Apache Web Server not working

  file, html, php, xampp

Picture of my path to upload

Trying to upload file to Apache server but not working. I think it is because I can’t write in the upload file or maybe something else. I am not really sure.

This is the snippet from the HTML form to upload the file:

<form enctype="multipart/form-data" action="upload.php" method="post">

  <input type="file" name="file" id="file">
  <input type="submit" id="u_button" name="u_button" value="Upload the file">
</form>

This is my PHP code to upload the file to the server:

<html>

<body>
  <?php
$filename=$_FILES['file']['name'];
$location = "upload/".$filename;

if(move_uploaded_file($_FILES['file']['tmp_name'],$location)){
    echo "<p>Worked</p>";
}
else{
    echo "<b>Try again</b>";
}
?>
</body>

</html>

Would appreciate any help:)

Source: Ask PHP

LEAVE A COMMENT