PHP form images uploaded to the server

Source: Internet
Author: User
Tags php form

This article is also written to their own view, because the writing is very concise, even the judgment is not, just directly realize the function can be uploaded.

Front desk:

  

<form action= "upload.php" method= "POST" enctype= "Multipart/form-data" >
<input type= "File" name= "MyFile"/>
<input type= "Submit" value= "Upload"/>
</form>

Background:

$name = $_files[' myfile ' [' Name '];//gets the path file name, the original name of the client machine file
$type = $_files[' myfile ' [' type '];//gets the file format, the MIME type of the file, which requires the browser to provide support for that information, such as "Image/gif"
$size = $_files[' myfile ' [' Size '];//gets the file size, the size of the uploaded file, in bytes
$tmp = $_files[' myfile ' [' tmp_name '];//file is uploaded and stored on the server after the temporary file name
$error =$_files[' myfile ' [' Error '];//and the file upload related error code
$uploads _dir= ' uploaded ';//Get the folder address where you want to store the picture
$rs =move_uploaded_file ($tmp, "$uploads _dir/$name");//upload pictures to the server

PHP form images uploaded to the server

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.