Hey everyone,
So I have an issue that I'm not sure how to solve. As for most of my posts, I'm sure it's an easy fix that I'm just not fully grasping. Anyway, I want to have a data form upload and show an image of the type of data that's being submitted. For example, if I upload a PDF file, I want it to show the image of the pdf as it shows in the folder it's being saved to. Is there a way to do this? maybe something like echo '<div><a href="files/', $name, '"><img src="files/', $name,'" /> ', $name, '</a></div>';
Here is my upload.php file
<?php
if(!empty($_FILES["file"])){
foreach($_FILES["file"]["name"] as $key => $name){
if($_FILES["file"]["error"][$key] == 0 && move_uploaded_file($_FILES['file']['tmp_name'][$key], "files/{$name}")){
$uploaded[] = $name;
}
}
}
?>
<html>
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<script type="text/javascript" src="upload.js"></script>
<style type="text/css">
#upload_progress{
display: none;
}
</style>
<title>File Upload</title>
</head>
<body>
<div id="uploaded">
<?php
if(!empty($uploaded)){
foreach($uploaded as $name){
echo '<div><a href="files/', $name, '"><img src="files/', $name,'" /> ', $name, '</a></div>';
}
}
?>
</div>
<div id="upload_progress"></div>
<div>
<form action="" method="post" enctype="multipart/form-data">
<div>
<input type="file" id="file" name="file[]" multiple="multiple" />
<input type="submit" id="submit" value="Upload" />
</div>
</form>
</div>
</body>
</html>
Thanks for any advice :D