SoFunction
Updated on 2025-04-09

All source codes of file upload programs

document

<html>
<body>
<title>File Upload</title>
<form enctype="multipart/form-data" action= method=post>
<input type=file name=upfile size=10><br><br>
<input type=submit value='upload file'>
</form>
</body>
</html>

<?
//Get the current date information and connect it to a string
$datetime = getdate();
$time = implode("",$datetime);
//Construct file name
//$filename="uploadfiles/".$time." ".$upfile_name;
$filename="uploadfiles/".$upfile_name;
//Storing the files on the server
$copymes = copy($upfile,$filename);
if ($copymes) {
print("File upload successfully!<br>n");
print("File name: $upfile_name<br>n");
print("Uploaded file size: $upfile_size<br>n");

}
else  print("File upload failed!<br>n");

if (($upfile_type=="image/gif")||($upfile_type=="image/pjpeg"))
{
//If it is in the graphic file format, it will be displayed
echo "<p><img src='";
echo $filename;
echo "'height=150 width=150 align=center border=0>";
}
?>

3. Just create a directory uploadfiles in the directory where the file above is located.

[The copyright of this article is jointly owned by the author and Aoso.com. If you need to reprint it, please indicate the author and source]