1

Can someone make sure I'm doing this correctly? It just won't upload. I'm banging my head on the table at the moment.

HTML:

<form method="post" enctype="multipart/form-data" style="text-align: center;">
  <input class="form-control" type="file" name="uploadFile" id="uploadFile" size="25">
  <button type="submit" name="submit" class="btn btn-success">Upload File</button>
</form>

PHP:

<?php
  if (isset($_POST['submit'])) {
    $is_file = is_uploaded_file($_FILES['uploadFile']['tmp_name']);
    $mv_file = move_uploaded_file($_FILES['uploadFile']['tmp_name'], "../users/gabriel.fraser/{$_FILES['uploadFile']['name']}");
    if ($is_file) {
      if ($file) {
        $message = '<div class="alert alert-success"><strong>Awesome!</strong> The file was uploaded successfully.</div>';
      } else {
        $message = "<div class='alert alert-danger'><strong>Oh snap!</strong> $mv_file </div>";
      }
    } else {
      $message = '<div class="alert alert-danger"><strong>Oh snap!</strong> The file failed to upload.</div>';
    }
  }
?>
brownzilla
  • 289
  • 2
  • 3
  • 12

0 Answers0