File upload demo with authentication. See screenshots here.
- Modify
src/config/db.php
based on your DB settings - Run Apache and MySQL Server
- Create tables using the following queries
CREATE TABLE Users (
id INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
email VARCHAR(50) NOT NULL UNIQUE,
password VARCHAR(255) NOT NULL
);
CREATE TABLE Files (
id INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
userid INT NOT NULL,
file_name VARCHAR(50) NOT NULL,
file_size VARCHAR(255) NOT NULL,
uploaded_at DATETIME DEFAULT CURRENT_TIMESTAMP,
CONSTRAINT fk_userid
FOREIGN KEY (userid)
REFERENCES Users(id)
ON DELETE CASCADE,
UNIQUE (userid, file_name)
);
- An email can only be used for registration once.
- Assume unique file names under the same user directory.
- MAMP
- Apache/2.4.43
- PHP/7.4.2
- MySQL/5.7.26