<div dir="ltr"><div>Also, missing space after "echo" keyword</div><div><br></div><div><span style="font-family:monospace">echo"Sorry, your file was not uploaded."; ) // <-------------------- ...rogue ')' from previous 'if' condition?<span class="gmail-im"><br></span></span></div><div><div><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div><br><br>===<br>Tai Kedzierski<br></div><div>Linux Operations and Deployments Engineer<br></div><br><div dir="ltr"><span></span><font size="1"><br>I use <a href="https://www.libreoffice.org/" target="_blank">LibreOffice</a> , a free, Freedom-respecting replacement for MS Office<br><br><i>Open Source Free Software is a matter of liberty, not price.</i><br>
<a href="https://www.fsf.org/about/what-is-free-software" target="_blank">https://www.fsf.org/about/what-is-free-software</a><br></font><font size="2"><br></font></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, 6 May 2020 at 12:37, Tai Kedzierski <<a href="mailto:dch.tai@gmail.com">dch.tai@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>Basically, a lot of syntax errors. It seems your PHP errors are not being reported to you in the browser, which you certainly want when debugging. Locate your php.ini file and amend as appropriate</div><div><br></div><div><a href="https://stackoverflow.com/questions/1053424/how-do-i-get-php-errors-to-display#21429652" target="_blank">https://stackoverflow.com/questions/1053424/how-do-i-get-php-errors-to-display#21429652</a></div><div><div><br></div><div>From just reading the code you posted, I noticed the following problems, there may be more, not actually tested.</div><div><br></div></div><div>+++</div><div><span style="font-family:monospace"><br></span></div><div><span style="font-family:monospace">HTML file<br><br>    <form action="upload.php" method="post" enctype="multipart/form-data"><br>        <input type="file" name="fileToUpload" id="fileToUpload"><br>        <input type="submit" value="Upload music file" name="submit"><br>    </form><br><br>upload.php<br><br>    <html><br>    <body><br><br><br>    <?php<br>    $target_dir = "Music/";<br>    $target_file = $target_dir . basename($_FILES["fileToUpload"]["name"]);<br>    $uploadOk = 1;<br>    $audioFileType = strtolower(pathinfo($target_file,PATHINFO_EXTENSION));<br><br>    // Check if file already exists<br>    echo First if; // <-------------------- quotes around string to be echoed<br>    if (file_exists($target_file)) {<br>        echo "Sorry, file already exists.";<br>        $uploadOk = 0;<br>    }<br>    echo Second if; // <-------------------- quotes<br>    // Allow certain file formats<br>    if($audioFileType != "mp3" && $audioFileType != "ogg"  { // <--------------------did not close condition with ')'  ...<br>        echo $audioFileType . <br> . "Sorry, only MP3 and OGG files are allowed.");<br>        $uploadOk = 0;<br>    }<br>    // Check if $uploadOk is set to 0 by an error<br>    echo Third if; // <-------------------- quotes<br>        echo"Sorry, your file was not uploaded."; ) // <-------------------- ...rogue ')' from previous 'if' condition?<br>    // if everything is ok, try to upload file<br>     else {<br>        Fourth if; // <-------------------- forgot "echo" keyword, quotes<br>        if (move_uploaded_file($_FILES ["fileToUpload"]["tmp_name"], $target_file)) {<br>            echo "The file ". basename( $_FILES["filndow.alerteToUpload"]["name"]). " has been uploaded."; }<br>        else {<br>            echo "Sorry, there was an error uploading your file." }<br>    }<br>    ?><br><br>    </body><br>    </html></span><br></div><div><div><div dir="ltr"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div><br><br>===<br>Tai Kedzierski<br></div><div>Linux Operations and Deployments Engineer<br></div><br><div dir="ltr"><span></span><font size="1"><br>I use <a href="https://www.libreoffice.org/" target="_blank">LibreOffice</a> , a free, Freedom-respecting replacement for MS Office<br><br><i>Open Source Free Software is a matter of liberty, not price.</i><br>
<a href="https://www.fsf.org/about/what-is-free-software" target="_blank">https://www.fsf.org/about/what-is-free-software</a><br></font><font size="2"><br></font></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, 6 May 2020 at 10:53, Andrew Ramage <<a href="mailto:andrew.ramage.1963@gmail.com" target="_blank">andrew.ramage.1963@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
  

    
  
  <div>
    <p>I tried working on the second half of my website (downloading)
      and the uploading part stopped working.  Can anyone see any reason
      for this ?  I added the echo statements to the file, but none
      display anything.<br>
    </p>
    <p><u>HTML file</u></p>
    <p><form action="upload.php" method="post"
      enctype="multipart/form-data"><br>
          <input type="file" name="fileToUpload"
      id="fileToUpload"><br>
          <input type="submit" value="Upload music file"
      name="submit"><br>
      </form><br>
    </p>
    <p><u>upload.php</u></p>
    <p><html><br>
      <body><br>
      <br>
      <br>
      <?php<br>
      $target_dir = "Music/";<br>
      $target_file = $target_dir .
      basename($_FILES["fileToUpload"]["name"]);<br>
      $uploadOk = 1;<br>
      $audioFileType =
      strtolower(pathinfo($target_file,PATHINFO_EXTENSION));<br>
      <br>
      // Check if file already exists<br>
      echo First if;<br>
      if (file_exists($target_file)) {<br>
          echo "Sorry, file already exists.";<br>
          $uploadOk = 0;<br>
      } <br>
      echo Second if;<br>
      // Allow certain file formats<br>
      if($audioFileType != "mp3" && $audioFileType != "ogg"  {<br>
          echo $audioFileType . <br> . "Sorry, only MP3 and OGG
      files are allowed.");<br>
          $uploadOk = 0;<br>
      } <br>
      // Check if $uploadOk is set to 0 by an error<br>
      echo Third if;<br>
          echo"Sorry, your file was not uploaded."; )<br>
      // if everything is ok, try to upload file<br>
       else {<br>
          Fourth if;<br>
          if (move_uploaded_file($_FILES ["fileToUpload"]["tmp_name"],
      $target_file)) {<br>
              echo "The file ". basename(
      $_FILES["filndow.alerteToUpload"]["name"]). " has been uploaded.";
      } <br>
          else {<br>
              echo "Sorry, there was an error uploading your file." }<br>
      }<br>
      ?><br>
      <br>
      </body><br>
      </html><br>
      <br>
    </p>
  </div>

-- <br>
EdLUG mailing list<br>
<a href="mailto:EdLUG@lists.edlug.org.uk" target="_blank">EdLUG@lists.edlug.org.uk</a><br>
<a href="https://lists.edlug.org.uk/mailman/listinfo/edlug" rel="noreferrer" target="_blank">https://lists.edlug.org.uk/mailman/listinfo/edlug</a></blockquote></div>
</blockquote></div>