Php implements code for uploading image files. _ PHP Tutorial

Source: Internet
Author: User
Php uploads the image file code ,. Php implements the code for uploading image files. the code is very simple. we will not talk nonsense here. we will directly provide the name $ name; $ nameErr of the source code php registry form; if ($ _ SERVER [REQUEST_MET php implements image file upload code,

The code is very simple. here we will not talk nonsense, and we will provide the source code directly.

<? Php // name of the registry ticket $ name = ""; $ nameErr = ""; if ($ _ SERVER ["REQUEST_METHOD"] = "POST ") {if (empty ($ _ POST ['name']) {} else {$ name = $ _ POST ['name']; if (! Preg_match ("/^ [a-zA-Z] * $/", $ name) {$ nameErr = "only letters and spaces are allowed ";} else {echo 'name '. $ name ;}// file upload if ($ _ FILES ["file"] ["type"] = "image/gif ") | ($ _ FILES ["file"] ["type"] = "image/jpeg ") | ($ _ FILES ["file"] ["type"] = "image/pjpeg ")) & ($ _ FILES ["file"] ["size"] <2000000) {if ($ _ FILES ["file"] ["error"]> 0) {echo "error :". $ _ FILES ["file"] ["error"]."
";} Else {echo" upload: ". $ _ FILES [" file "] [" name "]."
"; Echo" type: ". $ _ FILES [" file "] [" type "]."
"; Echo" size: ". $ _ FILES [" file "] [" size "]."
"; Echo" stored in :". $ _ FILES ["file"] ["tmp_name"] ;}} else {if (file_exists ("weiwei /". $ _ FILES ["file"] ["name"]) {echo $ _ FILES ["file"] ["name"]. "Upload successful. ";} else {move_uploaded_file ($ _ FILES [" file "] [" tmp_name "]," weiwei /". $ _ FILES ["file"] ["name"]); echo "Stored in :". "weiwei /". $ _ FILES ["file"] ["name"];} echo "uploaded" ;}}?> Registry ticket

The above is all the content of this article. I hope you will like it.

Pipeline, the code is very simple, here we will not talk nonsense, directly provide the source code php // registry ticket name $ name = ""; $ nameErr = ""; if ($ _ SERVER ["REQUEST_MET...

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.