Simple PHP file upload program

Source: Internet
Author: User
Tags file upload php file upload
The code is as follows: Copy code

<! Doctype html public "-// w3c // dtd xhtml 1.0 transitional // en" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<Html xmlns = "http://www.w3.org/1999/xhtml">
<Head>
<Meta http-equiv = "content-type" content = "text/html; charset = gb2312"/>
<Title> ultra-simple php file upload program </title>
</Head>

<Body>
<Form id = "form1" name = "form1" enctype = "multipart/form-data" method = "post" action = "">
<Label for = "filefield"> </label>
<Input type = "file" name = "name" id = "filefield"/>
<Input type = "submit" name = "button" id = "button" value = "start uploading files"/>
</Form>
</Body>
</Html>

<?
// File Upload

The code is as follows: Copy code
If ($ _ files)
{
Upfiles ($ _ files ,'./');
}
Function upfiles ($ files, $ path ){
Global $ nowtimestamp;
$ Exname = strtolower (substr ($ files ['name'], (strrpos ($ files ['name'], '.') + 1 )));
$ I = 1;
If (! Move_uploaded_file ($ files ['tmp _ name'], $ path. $ nowtimestamp. ".". $ exname )){
Showmessage ("failed to upload the file. Please try again later! ","? Job = add ", true );
 }
Return $ path. $ nowtimestamp. ".". $ exname;
}

?>

Related Article

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

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.