时间:2021-07-01 10:21:17 帮助过:4人阅读
enctype介绍:enctype属性指定将数据发回到服务器时浏览器使用的编码类型。
取值说明:
https://www.gxlcms.com/multipart/form-data: 窗体数据被编码为一条消息,页上的每个控件对应消息中的一个部分,不对字符编码。当使用有文件上传控件的表单时,该值是必需的。。
https://www.gxlcms.com/application/x-www-form-urlencoded: 窗体数据被编码为名称/值对。这是标准的编码格式。在发送前对所有字符进行编码(默认)。
https://www.gxlcms.com/text/plain: 窗体数据以纯文本形式进行编码,其中不含任何控件或格式字符,邮件处理中用到,其他地方很少用。将空格转换为 "+" 符号,但不编码特殊字符。抓包可见数据形式。
创建文件upload.html:
https://www.gxlcms.com/ 1https://www.gxlcms.com/https://www.gxlcms.com/DOCTYPE htmlhttps://www.gxlcms.com/>https://www.gxlcms.com/ 2https://www.gxlcms.com/<https://www.gxlcms.com/htmlhttps://www.gxlcms.com/>https://www.gxlcms.com/ 3https://www.gxlcms.com/<https://www.gxlcms.com/head https://www.gxlcms.com/langhttps://www.gxlcms.com/="en"https://www.gxlcms.com/>https://www.gxlcms.com/ 4https://www.gxlcms.com/<https://www.gxlcms.com/meta https://www.gxlcms.com/charsethttps://www.gxlcms.com/="UTF-8"https://www.gxlcms.com/>https://www.gxlcms.com/ 5https://www.gxlcms.com/<https://www.gxlcms.com/titlehttps://www.gxlcms.com/>UpLoad Filehttps://www.gxlcms.com/https://www.gxlcms.com/titlehttps://www.gxlcms.com/>https://www.gxlcms.com/ 6https://www.gxlcms.com/https://www.gxlcms.com/headhttps://www.gxlcms.com/>https://www.gxlcms.com/ 7https://www.gxlcms.com/<https://www.gxlcms.com/bodyhttps://www.gxlcms.com/>https://www.gxlcms.com/ 8https://www.gxlcms.com/<https://www.gxlcms.com/form https://www.gxlcms.com/actionhttps://www.gxlcms.com/="upload.php"https://www.gxlcms.com/ methodhttps://www.gxlcms.com/="post"https://www.gxlcms.com/ enctypehttps://www.gxlcms.com/="multipart/form-data"https://www.gxlcms.com/>https://www.gxlcms.com/ 9https://www.gxlcms.com/<https://www.gxlcms.com/input https://www.gxlcms.com/typehttps://www.gxlcms.com/="file"https://www.gxlcms.com/ namehttps://www.gxlcms.com/="file"https://www.gxlcms.com//>https://www.gxlcms.com/10https://www.gxlcms.com/<https://www.gxlcms.com/input https://www.gxlcms.com/typehttps://www.gxlcms.com/="submit"https://www.gxlcms.com/ valuehttps://www.gxlcms.com/="上传"https://www.gxlcms.com//>https://www.gxlcms.com/11https://www.gxlcms.com/https://www.gxlcms.com/formhttps://www.gxlcms.com/>https://www.gxlcms.com/12https://www.gxlcms.com/https://www.gxlcms.com/bodyhttps://www.gxlcms.com/>https://www.gxlcms.com/13https://www.gxlcms.com/https://www.gxlcms.com/htmlhttps://www.gxlcms.com/>
创建upload.php:
https://www.gxlcms.com/ 1 php https://www.gxlcms.com/ 2https://www.gxlcms.com//*https://www.gxlcms.com/* https://www.gxlcms.com/ 3https://www.gxlcms.com/ * Created by PhpStorm. https://www.gxlcms.com/ 4https://www.gxlcms.com/ * User: Administrator https://www.gxlcms.com/ 5https://www.gxlcms.com/ * Date: 2015/6/30 https://www.gxlcms.com/ 6https://www.gxlcms.com/ * Time: 19:02 https://www.gxlcms.com/ 7https://www.gxlcms.com/*/https://www.gxlcms.com/ 8https://www.gxlcms.com/ 9https://www.gxlcms.com///https://www.gxlcms.com/print_r($_FILES);//上传的所有文件都会存放在FILES数组里面https://www.gxlcms.com/10https://www.gxlcms.com/11https://www.gxlcms.com/$file = https://www.gxlcms.com/$_FILES['file'];https://www.gxlcms.com///https://www.gxlcms.com/获取文件https://www.gxlcms.com/12https://www.gxlcms.com/$fileName = https://www.gxlcms.com/$file['name'];https://www.gxlcms.com///https://www.gxlcms.com/获取文件名https://www.gxlcms.com/13https://www.gxlcms.com/move_uploaded_file(https://www.gxlcms.com/$file['tmp_name'],https://www.gxlcms.com/$fileName);https://www.gxlcms.com///https://www.gxlcms.com/移动图片到当前目录,php文件所在的目录https://www.gxlcms.com/14https://www.gxlcms.com/15https://www.gxlcms.com/echo "";https://www.gxlcms.com///https://www.gxlcms.com/输出图片
最终图片被保存在upload.php所在的目录并且在页面上显示出来
以上就介绍了PHP学习笔记12-上传文件,包括了方面的内容,希望对PHP教程有兴趣的朋友有所帮助。