All source code of the file upload Program

Source: Internet
Author: User

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]

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.