开发者

html type = file

With a html type=file, how can I tell if file was uploaded. Is there something in the $_POST values to indicate so?

<form action="program" enctype="multipart/form-data" method="post"&开发者_开发百科gt;
<input type="text" name="textline" size="30">
<input type="file" name="datafile">
<input type="submit" value="Send">
</form>


Check the $_FILES array:

if ($_FILES['datafile']['error'] == UPLOAD_ERR_OK) {
    // file was uploaded
}

'error' will match one of the predefined upload constants, see http://www.php.net/manual/en/features.file-upload.errors.php for all the possible values.


echo '<pre>';
var_dump($_FILES);
echo '</pre>';


The $_FILES variable contains information regarding file uploads, including original filename, mime type, temporary file name, error code and size of the uploaded file.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜