• <bdo id='c9FTa'></bdo><ul id='c9FTa'></ul>

      <legend id='c9FTa'><style id='c9FTa'><dir id='c9FTa'><q id='c9FTa'></q></dir></style></legend>
      <i id='c9FTa'><tr id='c9FTa'><dt id='c9FTa'><q id='c9FTa'><span id='c9FTa'><b id='c9FTa'><form id='c9FTa'><ins id='c9FTa'></ins><ul id='c9FTa'></ul><sub id='c9FTa'></sub></form><legend id='c9FTa'></legend><bdo id='c9FTa'><pre id='c9FTa'><center id='c9FTa'></center></pre></bdo></b><th id='c9FTa'></th></span></q></dt></tr></i><div id='c9FTa'><tfoot id='c9FTa'></tfoot><dl id='c9FTa'><fieldset id='c9FTa'></fieldset></dl></div>

      <small id='c9FTa'></small><noframes id='c9FTa'>

      <tfoot id='c9FTa'></tfoot>
    1. PHP 上传表格、PDF、Doc &amp;文档

      时间:2023-12-01

          <tbody id='vmfUF'></tbody>
        1. <legend id='vmfUF'><style id='vmfUF'><dir id='vmfUF'><q id='vmfUF'></q></dir></style></legend>

          <small id='vmfUF'></small><noframes id='vmfUF'>

          <i id='vmfUF'><tr id='vmfUF'><dt id='vmfUF'><q id='vmfUF'><span id='vmfUF'><b id='vmfUF'><form id='vmfUF'><ins id='vmfUF'></ins><ul id='vmfUF'></ul><sub id='vmfUF'></sub></form><legend id='vmfUF'></legend><bdo id='vmfUF'><pre id='vmfUF'><center id='vmfUF'></center></pre></bdo></b><th id='vmfUF'></th></span></q></dt></tr></i><div id='vmfUF'><tfoot id='vmfUF'></tfoot><dl id='vmfUF'><fieldset id='vmfUF'></fieldset></dl></div>
          • <tfoot id='vmfUF'></tfoot>
                <bdo id='vmfUF'></bdo><ul id='vmfUF'></ul>
                本文介绍了PHP 上传表格、PDF、Doc &amp;文档的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我正在努力使这个上传代码适用于 docx 文件,它适用于 doc 和 pdf..

                I'm struggling to make this upload code work for a docx file, it works okay for doc and pdf..

                $allowedExts = array("pdf", "doc", "docx");
                $extension = end(explode(".", $_FILES["file"]["name"]));
                if ((($_FILES["file"]["type"] == "application/pdf")
                || ($_FILES["file"]["type"] == "application/msword"))
                && ($_FILES["file"]["size"] < 20000000)
                && in_array($extension, $allowedExts))
                 {
                  if ($_FILES["file"]["error"] > 0)
                 {
                   echo "Return Code: " . $_FILES["file"]["error"] . "<br>";
                 }
                

                这是不久前的一个项目的一部分,老实说,我不记得该怎么做..

                this is part of a project from a while ago and i honestly can't remember how to do it..

                我知道这不是最安全的上传方法,但如果有人可以提供帮助,我们将不胜感激!

                I know it's not the most secure upload method, but if someone could help it would be appreciated!

                我想我需要在这里添加另一行:

                I'm thinking i need to add another line here:

                if ((($_FILES["file"]["type"] == "application/pdf")
                || ($_FILES["file"]["type"] == "application/msword"))
                && ($_FILES["file"]["size"] < 20000000)
                

                只是不确定是什么......感谢帮助!

                Just not sure what.. Help is appreciated!

                所以我已经到了这个阶段(在评论的帮助下!)

                So i've got to this stage (with the help of comments!)

                $allowedExts = array("pdf", "doc", "docx");
                $extension = end(explode(".", $_FILES["file"]["name"]));
                //if ((($_FILES["file"]["type"] == "application/pdf")
                //|| ($_FILES["file"]["type"] == "application/msword"))
                if (($_FILES["file"]["type"] == "application/pdf") 
                || ($_FILES["file"]["type"] == "application/msword") 
                || ($_FILES["file"]["type"] == "application/vnd.openxmlformats-    officedocument.wordprocessingml.document"))
                && ($_FILES["file"]["size"] < 20000000)
                
                && in_array($extension, $allowedExts))
                  {
                  if ($_FILES["file"]["error"] > 0)
                    {
                    echo "Return Code: " . $_FILES["file"]["error"] . "<br>";
                    }
                  else
                    {
                

                但现在它出现了:解析错误:语法错误,第 30 行/var/sites/s/stanation.com/public_html/forms/process/insert.php 中的意外 T_BOOLEAN_AND

                But now its coming up with: Parse error: syntax error, unexpected T_BOOLEAN_AND in /var/sites/s/stanation.com/public_html/forms/process/insert.php on line 30

                推荐答案

                对于 docx 检查这个 MIME 类型

                For docx check this MIME type

                application/vnd.openxmlformats-officedocument.wordprocessingml.document
                

                这是代码.你缺少括号

                <?php
                
                    $allowedExts = array("pdf", "doc", "docx");
                    $extension = end(explode(".", $_FILES["file"]["name"]));
                    if (($_FILES["file"]["type"] == "application/pdf") || ($_FILES["file"]["type"] == "application/msword") || ($_FILES["file"]["type"] == "application/vnd.openxmlformats-officedocument.wordprocessingml.document") && ($_FILES["file"]["size"] < 20000000) && in_array($extension, $allowedExts))
                    {
                      if ($_FILES["file"]["error"] > 0)
                      {
                         echo "Return Code: " . $_FILES["file"]["error"] . "<br>";
                      }
                      else
                      {
                        echo "Success";
                      }
                  }
                

                这篇关于PHP 上传表格、PDF、Doc &amp;文档的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                上一篇:为什么图片上传失败 php 的 is_uploaded_file 检查? 下一篇:解析上传的 CSV 文件并将数据存储到数据库

                相关文章

                • <bdo id='NWhZ7'></bdo><ul id='NWhZ7'></ul>
                <i id='NWhZ7'><tr id='NWhZ7'><dt id='NWhZ7'><q id='NWhZ7'><span id='NWhZ7'><b id='NWhZ7'><form id='NWhZ7'><ins id='NWhZ7'></ins><ul id='NWhZ7'></ul><sub id='NWhZ7'></sub></form><legend id='NWhZ7'></legend><bdo id='NWhZ7'><pre id='NWhZ7'><center id='NWhZ7'></center></pre></bdo></b><th id='NWhZ7'></th></span></q></dt></tr></i><div id='NWhZ7'><tfoot id='NWhZ7'></tfoot><dl id='NWhZ7'><fieldset id='NWhZ7'></fieldset></dl></div>

                  <tfoot id='NWhZ7'></tfoot>

                  <legend id='NWhZ7'><style id='NWhZ7'><dir id='NWhZ7'><q id='NWhZ7'></q></dir></style></legend>

                  <small id='NWhZ7'></small><noframes id='NWhZ7'>