Display uploaded file name below Button in PHP
I am trying to display the name of the uploaded file below the input button. The default text should say "No File Uploaded", once the file is selected and added to the server "file_name.ext was uploaded".
Here is my code at the moment:
<label for='upload' class='upload-button'></label><input type='file' name="fileAttach" class='upload-button' id='upload'/><br>Upload Site List
<?php
if (isset($_FILES['fileAttach']['name'])) {
echo "File is attached.";
}
?>
This code is on the form page using POST with enctype multipart/form-data.
My knowledge is below the entry level, so I'm sorry if this is really simple question. All the info I found so far did not help.
<label for='upload' class='upload-button'></label><input type='file' name="fileAttach" class='upload-button' id='upload'/><br>Upload Site List
<?php
if(isset($_FILES['fileAttach']['name'])) {
echo $_FILES['fileAttach']['name']." was uploaded";
}else{
echo "No File Uploaded";
}
?>
该表单将不得不提交给PHP以回应声明。
<form enctype="multipart/form-data" action="" method="POST">
<input type='file' name="fileAttach" class='upload-button' id='upload'/>
<input type="submit">
</form>
<br>Upload Site List<br>
<?php
if(isset($_FILES['fileAttach']['name'])) {
echo $_FILES['fileAttach']['name'] . " was uploaded";
} else {
echo "No File Uploaded";
}
?>
链接地址: http://www.djcxy.com/p/69744.html
上一篇: 表单字段稳定性php
下一篇: 在PHP中显示按钮下方的上传文件名