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 Tools

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft

EditPlus Chinese cracked version

EditPlus Chinese cracked version

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

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.