function AddPictureToUser($username, $source) { $loc = "members_bulkpics.php->AddPIctureToUser"; $userid = GetUserIDFromName($username); $userinfo = GetUserInfo($userid); if ($userinfo === false) { DieWithMsg($loc, 'User with ID=' . $userid . ' not found, but should be there.'); } // Copy the file into our website. $target = GetTempDir() . "temppic.jpg"; $result = @copy($source, $target); if ($result == false) { log_msg($loc, array('Picture not added. Unable to copy file.', 'External File=' . $source, 'Internal Target=' . $target)); return false; } $id = StoreUserPic($target, $userid); return true; }
if ($_SERVER["REQUEST_METHOD"] == "POST") { if (!isset($_POST["UserID"])) { DieWithMsg($loc, "Bad Post, no UserID."); } $userid = $_POST["UserID"]; $data = GetUserInfo($userid); if ($data === false) { DieWithMsg($loc, 'User with ID=' . $userid . ' not found.'); } $username = $data['UserName']; $lastname = $data['LastName']; $firstname = $data['FirstName']; PopulateParamList($param_list, $data); $result = CheckFileInput($error_msg, $tempfile); if ($result === true) { $id = StoreUserPic($tempfile, $userid); if ($id === false) { $error_msg = "Unable to save picture on server."; } else { $success_msg = "Picture successfully saved on server. Id=" . $id; } } } GenerateHtml: include "forms/header.php"; include "forms/navform.php"; include "forms/members_menubar.php"; include "forms/members_uploadpic_form.php"; include "forms/footer.php"; // -------------------------------------------------------------------- // Helper function to check the uploaded file and to get the name