PHP File Upload and move_uploaded_file introduction

Source: Internet
Author: User
<form action= "index.php Tutorial" method= "POST" enctype= "Multipart/form-data" >
Thumbnails: <input type= "file" name= "Files"/>
<input type= "Submit" value= "submitted"/>

PHP Processing Code

<?php
$temp _name = $_files[files][tmp_name]; Temporary file 3

$now _name = $_files[files][name]; Current File 4

Move_uploaded_file ($temp _name, './images/'. Date (' Yyyymdhis '). $now _name); Move to the specified folder below

?>

The Move_uploaded_file () function moves the uploaded file to a new location.

If successful, returns TRUE, otherwise returns false.

Grammar
Move_uploaded_file (file,newloc) parameter description
File required. Specify the files to be moved.
Newloc required. Specify a new location for the file.

Description
This function checks to make sure that files specified by file are valid uploads (that is, uploaded via Php's http post upload mechanism). If the file is valid, it is moved to the file specified by Newloc.

If file is not a legitimate upload file, no action occurs, Move_uploaded_file () returns false.

If file is a legitimate upload, but cannot be moved for some reason, Move_uploaded_file () will return false and a warning will be issued.

This check is particularly important if the uploaded file is likely to cause the content to be displayed to users or other users of the system.

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.