|
You must first build an HTML form that lets users select a file to upload. Select file to upload:
>
uploadfile.php code:
$target_path = "myfiles/";
$target_path = $target_path . basename( $_FILES[‘file’]['name']);
if(move_uploaded_file($_FILES[‘file’]['tmp_name'], $target_path)) { echo "The file ". basename( $_FILES[‘file’]['name'])." has been uploaded"; } else{ echo "Error Uploading File, Please try again."; }
$_FILES['file']['name'] It contains the original path of the user uploaded file.
$_FILES['file']['tmp_name'] It contains the path to the temporary file that resides on the server. The file should exist on the server in a temporary directory with a temporary name.
The include() Function: The include() function takes all the text in a specified file and copies it into the file that uses the include function. Example:
Welcome to The Home Page
|