Renaming Uploaded Files Before Saving Them to a Directory
In this context, the move_uploaded_file() function handles the preservation of uploaded files in a designated directory. To assign a random number as the file name, implement the following adjustments:
<br>$temp = explode(".", $_FILES"file");<br>$newfilename = round(microtime(true)) . '.' . end($temp);<br>move_uploaded_file($_FILES["file"]["tmp_name"], "../img/imageDirectory/" . $newfilename);<br>
The modified code accomplishes the following:
The above is the detailed content of How to Rename Uploaded Files Before Saving Them to a Directory?. For more information, please follow other related articles on the PHP Chinese website!