1. upfile. php file
<Html>
<Body>
<Title> File Upload </title>
<Form enctype = "multipart/form-data" action = upload. php method = post>
<Input type = file name = upfile size = 10> <br>
<Input type = submit value = 'upload file'>
</Form>
</Body>
</Html>
2. upload. php
<?
// Obtain the current date and connect it to a string
$ Datetime = getdate ();
$ Time = implode ("", $ datetime );
// Construct the file name
// $ Filename = "uploadfiles/". $ time. "". $ upfile_name;
$ Filename = "uploadfiles/". $ upfile_name;
// Stores the file on the server.
$ Copymes = copy ($ upfile, $ filename );
If ($ copymes ){
Print ("File Uploaded successfully! <Br> n ");
Print ("File Name: $ upfile_name <br> n ");
Print ("Size of the uploaded file: $ upfile_size <br> n ");
}
Else print ("File Upload Failed! <Br> n ");
If ($ upfile_type = "image/gif") | ($ upfile_type = "image/pjpeg "))
{
// Display the image file format
Echo "<p> Echo $ filename;
Echo "'height = 150 width = 150 align = center border = 0> ";
}
?>
3. Create a directory named uploadfiles in the directory where the above file is located.
[This article is copyrighted by the author and osuo. If you need to reprint it, please indicate the author and its source]