PHP上传表格

Zha*_*haf 0 php

我想构建一个工作的上传文件表单,我在本教程中使用代码 - http://www.w3schools.com/PHP/php_file_upload.asp

一切都很好.唯一的问题是,原始代码只包含gif和jpg的文件类型.我也需要png.

我所做的是修改这一行:

    > if ((($_FILES["file"]["type"] == "image/gif")
    || ($_FILES["file"]["type"] == "image/jpeg")
    || ($_FILES["file"]["type"] == "image/pjpeg"))
Run Code Online (Sandbox Code Playgroud)

对此:

if ((($_FILES["file"]["type"] == "image/gif")
|| ($_FILES["file"]["type"] == "image/jpeg")
|| ($_FILES["file"]["type"] == "image/pjpeg"))
|| ($_FILES["file"]["type"] == "image/png"))
Run Code Online (Sandbox Code Playgroud)

但它会变成错误.有什么建议?

Kin*_*xit 5

在pjpeg之后删除额外的)使它看起来像这样:

if (($_FILES["file"]["type"] == "image/gif") || 
($_FILES["file"]["type"] == "image/jpeg") || 
($_FILES["file"]["type"] == "image/pjpeg") || 
($_FILES["file"]["type"] == "image/png"))
Run Code Online (Sandbox Code Playgroud)

还有一个额外的(在我删除的IF之前,但这可能是你的复制粘贴问题.