\t\t </form> \t </body> \t </html> BODY; echo generatePage($body); $iw = new ImageWorker(new Credentials("localhost", "user", "user", "calendapp")); if (isset($_POST['submit'])) { if (isset($_SESSION['username'])) { $username = $_SESSION['username']; } else { $username = "******"; } $tags = $_POST['tags']; $caption = $_POST['caption']; if ($id = $iw->uploadImage($username, $tags, $caption)) { //echo "Successful upload with id $id"; //Placeholder echo "<script> alert('Successfully uploaded image!')</script>"; header("Location: main.php"); } else { echo "<script> alert('Upload failed. (" . $iw->getError() . ")')</script>"; } } ?> <script> window.onsubmit = validateForm; //At least 2 tags function validateForm() { var tags = document.getElementById("tags").value;
<?php require_once "support.php"; require_once "uploadimage.php"; require_once "dbLogin.php"; //$body =<<<BODY ?> <form action="uploadtest.php" enctype="multipart/form-data" method="post"> <p> <b>Enter image to upload: </b> <input type="file" name="filename" /><br /> <input type="submit" name='submit' value="uploadImage" /> </p> </form> <?php echo generatePage($body); $iw = new ImageWorker(new Credentials("localhost", "user", "user", "calendapp")); if (isset($_POST['submit'])) { if ($id = $iw->uploadImage("test", "nothing", "hello world")) { echo "Successful upload with id {$id}"; } }