First the effect picture: Create Form in
Sample6_1.php:
Copy code The code is as follows:
//Display upload status and pictures
Copy code The code is as follows:
function uploadimg(theform){
/ /Submit Form
theform.submit();
//Show upload status in showimg
Copy code The code is as follows:
//Provide image type verification
$allowedtypes = array("image/jpeg ","image/pjpeg","image/png", "image/x-png","image/gif");
//File storage directory
$savefolder = "images";
//If there are files uploaded Let’s start working
if (isset ($_FILES['myfile'])){
//Check whether the uploaded file matches the $allowedtypes type
if (in_array($_FILES['myfile']['type'],$allowedtypes )){
if ($_FILES['myfile']['error'] == 0){
$thefile = "$savefolder/".$_FILES['myfile']['name'];
//Pass move_uploaded_fileUpload file
if (!move_uploaded_file($_FILES['myfile']['tmp_name'], $thefile)){
echo "There was an error uploading the file.";
}
else{
?>
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
< html xmlns="http://www.w3.org/1999/xhtml">