Im building a photo album application where when you upload a picture it gets saved in a photos directory of my XAMPP server. Now I need to access the names of the files of those photos from the photos directory so that I can show them again. How to do this with javascript?
<?php
if(isset($_FILES['image'])){
$error = arraY();
$file_name = $_FILES['image']['name'];
$file_size = $_FILES['image']['size'];
$file_tmp = $_FILES['image']['tmp_name'];
$file_type = $_FILES['image']['type'];
$hello = explode('.',$_FILES['image']['name']);
$hello2 = end($hello);
$file_ext = strtolower($hello2);
$extensions = array('jpeg','jpg','png');
if(in_array($file_ext,$extensions)==false){
$error[] = "Please choose the image which has the extension as jpeg,jpg,png";
}
if(empty($error) == true){
move_uploaded_file($file_tmp,"images/".$file_name);
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<h3>Image Upload</h3>
<form action="album.php" method="POST" enctype="multipart/form-data" id="form">
<input type="file" name="image" id="image">
<input type="submit" value="Upload">
</form>
<ul class="photoalbum"></ul>
</body>
</html>