I have tried a number of things and all of them have crashed. My code is below. I am writing code for a form to upload three photos and this code works fine to upload three photos.
What I am stuck with is:
1) I would like the form to echo out a statement that says the "File already exists" and not overwrite the existing file
and
2) I would like the form to echo out the details of the three files and that they were successfully uploaded after this is executed.
Any help would be appreciated!
Thanks in advance.
<?php
if (isset($_FILES['upload']) === true) {
$files = $_FILES['upload'];
for($x = 0; $x < count($files['name']); $x++){
$name = $files['name'][$x];
$tmp_name = $files['tmp_name'][$x];
move_uploaded_file($tmp_name, 'uploads/' . $name);
}
}
?>
<form action="" method="post" enctype="multipart/form-data">
<table border="0" width="400" cellspacing="0" cellpadding="0" align="center">
<tr><td>Photo 1</td><td><input type="file" name="upload[]"></td></tr>
<tr><td>Photo 2</td><td><input type="file" name="upload[]"></td></tr>
<tr><td>Photo 3</td><td><input type="file" name="upload[]"></td></tr>
<tr><td colspan="2" align="center"><input type="submit" value="Upload Photos"></td></tr>
</table>
</form>