php method to upload files and replace them: first create two files, namely "change.html" and "change.php"; then use "strrchar()" to process the files; then call to determine the file type function and convert it to lowercase; finally upload and replace the file.
The operating environment of this article: windows7 system, PHP7.1 version, DELL G3 computer
How to upload image files with php and Replace
First create two files: change.html and change.php
The form code of the change.html file is as follows:
<html> <head> <title>change file example.</title> <meta charset="UTF-8"> </head> <body> <form method="post" action="changefile.php" enctype="multipart/form-data"> <table border=0 cellspacing=0 cellpadding=0 align=center width="100%"> <tr> <td width=55 height=20 align="center"> <input type="hidden" name="MAX_FILE_SIZE" value="2000000" /> 文件: </td> <td> <input name="file" type="file" /> <input type="submit" name="submit" value="submit" /> </td> </tr> </table> </form> </body> </html>
There are several requirements here Things to pay attention to, first look at this sentence