search
Homephp教程php手册php 文件上传实例教程

php 文件上传实例教程

Jun 13, 2016 am 10:09 AM
movephpuploadExampleusTutorialdocumentof

好了我们来看看最简单的php 文件上传实例教程吧,我们会用到move_uploaded_file 来把本地文章上传到服务器上去.

好了我们来看看最简单的php 文件上传实例教程吧,我们会用到move_uploaded_file 来把本地文章上传到服务器上去.

用PHP ,可以上传文件到服务器。


-------------------------------------------------- ------------------------------

建立一个上传文件表格
为了让用户上传文件的形式可以是非常有益的。

看看下面的HTML表单的文件上传:


            



            

请注意以下的HTML表单上面:

该是enctype属性

标记指定的内容类型时使用的形式提交。 “多/形式的数据”时使用的一种形式,需要二进制数据,如文件内容,将上传
该类型= “文件”属性指定标记的投入应该是处理文件。例如,当观看在浏览器中,将有浏览按钮,旁边的输入栏位
注:允许用户上传文件是一个很大的安全风险。只允许受信任的用户进行文件上传。


创建上传脚本
该“ upload_file.php ”文件中包含的代码上传文件:

move_uploaded_file($_FILES["file"]["tmp_name"],
      "upload/" . $_FILES["file"]["name"]);
      echo "Stored in: " . "upload/" . $_FILES["file"]["name"];

就这么简单.

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function