STEP 5
Move uploaded file from computer to server.
This Php Function move the files from your computer to your server. This part is the active part of this upload script.
You must define next strings that have made the uplading in upload.php
$pcfile= $_FILES['userfile']['tmp_name'];
$uploaddir = 'upload/';
$uploadfile = $uploaddir.$_FILES['userfile']['name'];
$userfile =$_FILES['userfile']['name'];
the condition for validation is:
elseif (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 function move the files from browser to hosting server
$uploaddir = 'upload/'; - upload directory in our case folder named upload
$uploadfile = $uploaddir.$_FILES['userfile']['name']; - adress for uploaded files
!! 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
» STEP 6: DEMO PAGE -PHP UPLOAD SCRIPT IN ACTION
» STEP 7: DOWNLOAD THE SCRIPT