Exemplo n.º 1
0
<?php

include_once "_classes/user.php";
session_start();
$uid = $_SESSION['uid'];
$message = $_POST['message'];
$target_dir = "_resources/uploads/{$uid}/";
$target_file = $target_dir . basename($_FILES["fileToUpload"]["name"]);
$uploadOk = 1;
if (isset($_POST["submit"])) {
    $uploadOk = 1;
}
if ($uploadOk == 0) {
    echo "Sorry, your file was not uploaded.";
    // if everything is ok, try to upload file
} else {
    if (move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $target_file)) {
        echo "The file " . basename($_FILES["fileToUpload"]["name"]) . " has been uploaded.";
        $db = new MyDB();
        $db->insertHistory($uid, basename($_FILES["fileToUpload"]["name"]), $message);
        $db->close();
    } else {
        echo "Sorry, there was an error uploading your file.";
    }
}