This project is a dynamic file upload form built using PHP, MySQL, and jQuery. It allows users to upload files and view them dynamically. Additionally, it includes an admin login system for secure access to the upload area. The project uses modern practices, such as PDO for database interactions, session-based authentication, and role-based access control.
-
Secure Admin Area:
- Only authorized users can access the upload functionality.
- Admin users must log in with valid credentials.
-
File Upload System:
- Supports uploading files to a dedicated
uploads/
directory. - Stores file information in a MySQL database.
- Supports uploading files to a dedicated
-
File Management:
- Dynamically displays a list of uploaded files.
-
User Management:
- Includes a login system for admins.
- Role-based access ensures non-admins cannot access restricted pages.
-
Secure Code:
- Uses prepared statements to prevent SQL injection.
- Passwords are hashed with
password_hash
for secure storage.
-
Optional Admin Registration:
- A separate registration page allows adding new admin users.
- A web server with PHP 7.4 or higher (e.g., Apache or Nginx).
- MySQL database.
- Basic knowledge of setting up PHP projects.
-
Clone the Repository:
git clone https://github.com/marinnedea/dynamic-PHP-MySQL-jQuery-upload-form.git cd dynamic-PHP-MySQL-jQuery-upload-form
-
Set Up the Database:
- Import the provided
accounts.sql
file into your MySQL database:mysql -u your_username -p your_database_name < accounts.sql
- Update the database credentials in the following files:
index.php
login.php
register.php
(if used)
- Import the provided
-
Set Directory Permissions:
- Ensure the
uploads/
directory is writable by the web server:mkdir uploads chmod 755 uploads
- Ensure the
-
Access the Project:
- Open your browser and navigate to the project:
login.php
: Admin login page.register.php
(Optional): Register a new admin user.index.php
: Admin area for uploading and viewing files (accessible only after login).
- Open your browser and navigate to the project:
- Navigate to the
login.php
page. - Log in using the default admin credentials (if provided) or create a new admin user via
register.php
.
- After logging in, upload files using the form on
index.php
. - Uploaded files are saved in the
uploads/
directory and listed dynamically.
- Click the Logout link to end your session.
dynamic-PHP-MySQL-jQuery-upload-form/
│
├── index.php # Main file upload area (admin only)
├── login.php # Admin login page
├── register.php # Optional admin registration page
├── logout.php # Ends the admin session
├── uploads/ # Directory where uploaded files are stored
├── accounts.sql # SQL file to set up the users table
├── README.md # Project documentation
- Authentication: Only authenticated users can access the upload form.
- Password Hashing: Passwords are hashed before storing them in the database.
- SQL Injection Prevention: All database interactions use prepared statements.
- Role-Based Access Control: Only users with the
admin
role can access the admin area.
- Add a progress bar for file uploads using jQuery.
- Implement file type and size validation on both client and server sides.
- Add a feature for admin users to delete uploaded files.
- Enhance the UI with modern CSS frameworks (e.g., Bootstrap or TailwindCSS).
Feel free to submit issues or contribute to the project. Pull requests are welcome!
- Fork the repository.
- Create a feature branch (
git checkout -b feature-branch
). - Commit your changes (
git commit -m "Description of changes"
). - Push to your branch (
git push origin feature-branch
). - Open a pull request.
This project is licensed under the MIT License. See the LICENSE file for details.
For any inquiries or support, feel free to contact Marin Nedea.