Answers for "upload image and save in folder using php"

PHP
2

php image upload write to server

<?php error_reporting(0);

$msg = "";

if ( isset( $_POST['upload']) ) {

	$filename = $_FILES["uploadfile"]["name"];
	$tempname = $_FILES["uploadfile"]["tmp_name"];
    $folder   = $filename;

    if ( move_uploaded_file( $tempname, $folder ) ) {
        $msg = "Image uploaded successfully";
    } else{
        $msg = "Failed to upload image";
	}
}
?>

<!DOCTYPE html>
<html>
    <head>
    <title>Image Upload</title>
    </head>
    <body>

    <h2><?php echo $msg; ?></h2>
    <form method="POST" action="" enctype="multipart/form-data">
        <input type="file" name="uploadfile"/>
        <button type="submit" name="upload">UPLOAD</button>
    </form>
    </body>
</html>
Posted by: Guest on June-17-2021
0

how to upload image in php and store in database and folder

// Get the name of images
  	$Get_image_name = $_FILES['image']['name'];
  	
  	// image Path
  	$image_Path = "images/".basename($Get_image_name);

  	$sql = "INSERT INTO student_table (imagename, contact) VALUES ('$Get_image_name', 'USA')";
  	
	// Run SQL query
  	mysqli_query($conn, $sql);

  	if (move_uploaded_file($_FILES['image']['tmp_name'], $image_Path)) {
  		echo "Your Image uploaded successfully";
  	}else{
  		echo  "Not Insert Image";
  	}
  }
Posted by: Guest on July-07-2020

Code answers related to "upload image and save in folder using php"

Browse Popular Code Answers by Language