doulun0651 2018-11-20 17:53
浏览 53

附加pdf大于2mb

the file storage is limited to 2mb. I've already tried everything, as shown in this https://kinsta.com/blog/wordpress-maximum-upload-file-size/ and I can not increase the file upload limit size. I leave here the code I'm using to see if it's possible to increase the size of the upload within the php code:

$Valencia = $_POST["Valencia"];
$dataInicio = $_POST["dataInicio"];
$dataFim = $_POST["dataFim"];
$pathToSave = "/var/www/html/wordpress/wp-content/themes/busiprof/Upload/";

/*Checa se a pasta existe - caso negativo ele cria*/
if (!file_exists($pathToSave)) {
    mkdir("$pathToSave", 0777);
}

if ($_FILES) { // Verificando se existe o envio de arquivos.

    if ($_FILES['txtArquivo']) { // Verifica se o campo não está vazio.
        $dir = $pathToSave; // Diretório que vai receber o arquivo.
        $tmpName = $_FILES['txtArquivo']['tmp_name']; // Recebe o arquivo temporário.

        $name = $_FILES['txtArquivo']['name']; // Recebe o nome do arquivo.
        preg_match_all('/\.[a-zA-Z0-9]+/', $name, $extensao);
        if (!in_array(strtolower(current(end($extensao))), array('.txt', '.pdf', '.doc', '.xls', '.xlms'))) {
            echo('Permitido apenas arquivos doc,xls,pdf e txt.');

            die;
        }

        // move_uploaded_file( $arqTemporário, $nomeDoArquivo )
        if (move_uploaded_file($tmpName, $dir.$name)) { // move_uploaded_file irá realizar o envio do arquivo.        
            echo('Arquivo adicionado com sucesso.');
        } else {
            echo('Erro ao adicionar arquivo.');
        }   

$conn->query("INSERT INTO UploadPDF (Valencia,dataInicio,dataFim,txtArquivo) VALUES ('$Valencia','$dataInicio','$dataFim','$name')");       
    }  
}

if attach a pdf of 15 mb directly in wordpress, the pdf is attached, but if it is by the above code, it inserts the name in the table of the database, but does not insert the pdf in the folder inside the server

  • 写回答

1条回答 默认 最新

  • dqydp44800 2018-11-20 18:05
    关注

    Did you tried to update your php.ini file vars?

    ; Maximum allowed size for uploaded files.
    upload_max_filesize = 20M
    
    ; Must be greater than or equal to upload_max_filesize
    post_max_size = 20M
    

    Another way you can try is adding this at the top of your code:

    ini_set('upload_max_filesize', '20M')
    ini_set('post_max_size', '20M')
    

    Where 20M is the max file size that you want.

    评论

报告相同问题?

悬赏问题

  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?
  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算