コード例 #1
0
ファイル: newPost.php プロジェクト: Travelite/Travelite
    $imageName = $image['name'];
    $imagesDir = "post_pictures/";
    $thumbsDir = $imagesDir . "thumbs/";
    if (!file_exists($imagesDir)) {
        $permission = 0777;
        mkdir($imagesDir, $permission);
        mkdir($thumbsDir, $permission);
    }
    $imagePath = $imagesDir . $imageName;
    $thumbPath = $thumbsDir . $imageName;
    //$extension = pathinfo($imgPath, PATHINFO_EXTENSION);
    $uploaded = move_uploaded_file($imageTempDir, $imagePath);
    if ($uploaded) {
        $imageURL = $imagePath;
        $thumbURL = $thumbPath;
        squareImageAtPath($imagePath, $thumbPath, 100);
    } else {
    }
}
$submitted = isset($_POST['submit']) ? true : false;
$postTitle = isset($_POST['title']) ? $_POST['title'] : NULL;
$postBody = isset($_POST['body']) ? nl2br($_POST['body']) : NULL;
$responseMsg = NULL;
if ($submitted) {
    $inserted = insertNewPost($myUserID, $postTitle, $postBody, $imageURL, $thumbURL);
    if ($inserted['success']) {
        header("Location:index.php");
    } else {
        $responseMsg = $inserted['response'] . "<br><br>";
    }
}
コード例 #2
0
ファイル: editUser.php プロジェクト: Travelite/Travelite
    $submittingDetails = $_POST;
    if ($updatedImage) {
        $image = $_FILES['avatar'];
        $imageTempDir = $image['tmp_name'];
        $imageName = $image['name'];
        $imagesDir = "avatars/";
        $permission = 0777;
        if (!file_exists($imagesDir)) {
            mkdir($imagesDir, $permission);
        }
        $imagePath = $imagesDir . $imageName;
        $uploaded = move_uploaded_file($imageTempDir, $imagePath);
        if ($uploaded) {
            $imageURL = $imagePath;
            $submittingDetails['profileImage'] = $imageURL;
            squareImageAtPath($imagePath, $imagePath, 200);
        }
    }
    if (isValidEmail($_POST['emailAddress'])) {
        updateUserForID($myUserID, $submittingDetails);
    } else {
        $errorMsg = "<b>* Invalid email address</b><br><br>";
    }
}
$user = getUserForID($myUserID);
$profilePicURL = $user['profileImage'] ? $user['profileImage'] : NULL;
$profilePic = file_exists($profilePicURL) ? $profilePicURL : "images/default.png";
$fullName = $user['fullName'] ? $user['fullName'] : "No name set";
$username = $user['username'] ? $user['username'] : "******";
$emailAdd = $user['emailAddress'] ? $user['emailAddress'] : "No email address set";
?>