I am attempting to hide an image box until a file has been set within my file upload code. Right now it shows the $preview image box regardless if a file has been set.
What am I doing wrong?
<form action="" method="POST" enctype="multipart/form-data">
Change your profile picture <br><input type="file" name="file" class="inputbarfile" onchange="readURL(this);">
<?php
$preview_file = '<input type="file" name="file" class="inputbarfile" onchange="readURL(this);">';
$preview = '<img width="300px" height="200px" id="file" src="#" alt="your image">';
if (empty($preview_file)) {
'';
} else {
echo $preview;
} ?>
<input type="submit" name="create" value="Upload">
</form>
Aucun commentaire:
Enregistrer un commentaire