In this PHP tutorial we will provide a step by step guide to producing your very own php file upload script to use for your website. Before we start you must have Xampp installed, view the tutorial on how to install Xampp.
Firstly create an index.php file now it is recommended that you should use an editor of some kind, i personally use this free PHP IDE editor to edit .php files. However you can simple use notepad (by changing the .php extension to .txt) to edit but may become annoying to keep changing the extension back and forth each time you want to test the page file.
We will now edit the index.php file you have just created by inserting the following code:
<?php
session_start():
$_SESSION("name") = "Admin";
<html>
<form action'process.php' method='POST' enctype='multipart/form-date'>
<label> Upload your file (5kb - 2000kb) :</label>
<input type='file' name='file'>
<input type="submit" name="submit" value="upload">;
</form>
You can now view index.php in your web browser and see that there is an upload field to browse the file you wish to upload, however uploading afile will not function since we still need to create the code for the process.
Now Create a file called process.php and then create a folder called upload, place these two files in the same directory as your index.php file.
Insert the following code into your process.php file
<?php
session_start();
include "connect.php";
if ($_POST ["submit"])
{
//Coding
if($_SESSION["name"])
{
// variables
}
else
{
echo "please sign in";
}
else
{
echo "<a href='index.php'>"
}
The first part of the code checks if the user has clicked the submit
button,
if ($_POST ["submit"])
We must now declare all the variables in order to do that we must create a database, next open your web browser and go to:
http://localhost/phpmyadmin/
create a new database, call it test, select the database and create a new table and name it: imageupload
enter 3 in the number of fields box and then click go, next enter the following values for each setting:
Field (1st coloumn): id
Field (2nd coloumn): user
Field (3rd coloumn): location
Type (1st coloumn): INT
Type (2nd coloumn): VARCHAR
Type (3rd coloumn): TEXT
Length/Values (2nd coloumn): 100
Index (1st coloumn): Primary
Auto Increment (1st coloumn): [check box]
your table should look like the screenshot below:
Next click save.



The code to edit the index.php file is easy to follow. Thanks.
simple & cool ! thanks !