开发者

$_FILES and form enctype

开发者 https://www.devze.com 2023-03-12 04:01 出处:网络
If a form has not file element and enctype=\"multipart/form-data\" properties is setted, $_FILES always is setted as an empty arr开发者_如何学编程ay, right? I have to know for handling upload and doin

If a form has not file element and enctype="multipart/form-data" properties is setted, $_FILES always is setted as an empty arr开发者_如何学编程ay, right? I have to know for handling upload and doing nothing about upload. How can I distinguish $_FILES['name']['error'] > 0 or isset($_FILES[0]) ?

If form has file element, $_FILES['name']['error'] > 0

If form hasn't file element, isset($_FILES[0])


Make three pages.

  • page 1: has a form, no enctype, no file input
  • page 2: has a form, no enctype, a file input
  • page 3: has a form, proper enctype, a file input

Have each form print_r($_FILES, $_POST) below the <form> html.

Test.


You're asking how can you test to see if form has the upload field not filled in?

http://ca.php.net/manual/en/function.empty.php

0

精彩评论

暂无评论...
验证码 换一张
取 消