STEP 5
Move uploaded file from computer to server.
This Php Function ( move_uploaded_file ) move the files from your computer to your server. This part is the active part of this upload script.
You have to define the strings that are involved in upload script in upload.php page:
//======================
$uploaddir = 'upload/'; // upload directory
$file_name = $uploaddir.$_FILES['userfile']['name']; // uploaded file
$userfile =$_FILES['userfile']['name']; // your pc file
//======================
upload validation php code:
//==============
if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploaddir.str_replace(' ', '_', $file_name))){
echo '<center><font color=green>The file <strong>"'.$_FILES['userfile']['name'].'"</strong> successfully uploaded';
}
//============
You have to create a folder named upload in the same directory with the file upload.php or upload.html + upload.php
move_uploaded_file - this is the Php function wich move the files from browser to hosting server .
//==========
$uploaddir = 'upload/'; - upload directory in our case is folder named upload
$file_name = $uploaddir.$_FILES['userfile']['name']; - adress for uploaded files
//==========
!!Note You must set the CHMOD of the upload folder in FTP server (right click and then select CHMOD to 777 if the hosting server are this option disabled ).
Message in this validation case is :
The file "example.JPG" successfully uploaded
You can change the text but not this part "'.$_FILES['userfile']['name'].'"
» CREATE HTML ( PHP ) FORM
» STEP 2 : VALIDATION PHP : CHECK FILE EXTENSION IF IS ALOWED / NOT ALLOWED TO BE UPLOADED
» STEP 3 : VALIDATION PHP : CHECK IF A FILE WITH THE SAME NAME EXIST ON SERVER
» STEP 4 : VALIDATION PHP : CHECK THE FILE MAXIMUM SIZE
» STEP 5 : MOVE UPLOAD FILE IN UPLOAD DIRECTORY ON SERVER