This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Axios from "axios"; | |
import { API_URL } from "../models/constants"; | |
export const uploadImage = async (token, imageUrl) => { | |
const fileBlob = await urlToObject(imageUrl); | |
var bodyFormData = new FormData(); | |
bodyFormData.append('file', fileBlob); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { useState } from 'react'; | |
import getToken from '../api_client/auth'; | |
import { uploadImage } from '../api_client/files'; | |
import { createUser } from '../api_client/user'; | |
import '../App.css'; | |
const CreateUserPage = () => { | |
const [publicName, setPublicName] = useState(""); | |
const [password, setPassword] = useState(""); | |
const [email, setEmail] = useState(""); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* This is a short snapshot to show an idea. The complete project is tored here: | |
* https://github.com/wildroo/medium/blob/main/react_php_task | |
*/ | |
class UserHelper{ | |
private $usersTable = "users"; | |
private $profilesTable = "profiles"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
header("Content-Type: application/json; charset=UTF-8"); | |
include_once '../config/dbconfig.php'; | |
include_once '../helpers/userHelper.php'; | |
$db = new DBClass(); | |
$userHelper = new UserHelper(); | |
//$data = $connection->query('SELECT NOW()'); | |
//print_r($data); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class DBClass { | |
private $host = "<your_host>"; | |
private $username = "<your_user_name>"; | |
private $password = "<your_passowrd>"; | |
private $database = "<your_db_name>"; | |
public $connection; |