web learning

HTML

CSS

PHP

JAVA SCRIPT

AJAX

EBOOKS

PROJECT

FORUM

<form action="listing15-1.php" enctype="multipart/form-data" method="post">
  <label form="email">Email:</label><br />
  <input type="text" name="email" value="" /><br />
  <label form="classnotes">Class notes:</label><br />
  <input type="file" name="classnotes" value="" /><br />
  <input type="submit" name="submit" value="Submit Notes" />
</form>
<?php

// Set a constant
define ("FILEREPOSITORY","/uploads/");

// Make sure that the file was POSTed.
if (is_uploaded_file($_FILES['classnotes']['tmp_name'])) {
    // Was the file a PDF?
    if ($_FILES['classnotes']['type'] != "application/pdf") {
        echo "<p>Class notes must be uploaded in PDF format.</p>";
    } else {
        // Move uploaded file to final destination.
        $name = $_POST['name'];
        echo $_FILES['classnotes']['tmp_name']."<br />";
        $result = move_uploaded_file($_FILES['classnotes']['tmp_name'],
                                                        FILEREPOSITORY.$_FILES['classnotes']['name']);
        echo FILEREPOSITORY.$_FILES['classnotes']['name']."<br />";
       if ($result == 1) echo "<p>File successfully uploaded.</p>";
           else echo "<p>There was a problem uploading the file.</p>";
    }
}
?>

Categories:

Leave a Reply