文件上传失败通过HTTPS

时间:2019-05-20 06:20:44

标签: php apache

我有一个文件上传php脚本,在通过常规http时运行良好。但是,当我使用自签名证书配置服务器时,它不再上载文件。我怀疑move_uploaded_file现在应该有所不同,但是不能很好地说明如何修复。谢谢。

<?php

$fileName = $_FILES["file1"]["name"]; // The file name

$fileTmpLoc = $_FILES["file1"]["tmp_name"]; // File in the PHP tmp folder

$fileType = $_FILES["file1"]["type"]; // The type of file it is

$fileSize = $_FILES["file1"]["error"]; // 0 for false... and 1 for true

if (!$fileTmpLoc) { // if file not chosen

    echo "ERROR: Please browse for a file before clicking the upload button.";

    exit();

}

if(move_uploaded_file($fileTmpLoc, "uploads/{$fileName}")) {

    echo "$fileName upload is complete";

} else {

    echo "move_uploaded_file function failed";

}


?>

这是我的/etc/apache2/sites-available/default-ssl.conf,不带注释。

<IfModule mod_ssl.c>
        <VirtualHost _default_:443>
                ServerAdmin bishop@gmail.com
                ServerName 192.168.236.138

                DocumentRoot /var/www/html

                ErrorLog ${APACHE_LOG_DIR}/error.log
                CustomLog ${APACHE_LOG_DIR}/access.log combined

                SSLEngine on

                SSLCertificateFile      /etc/ssl/certs/apache-selfsigned.crt
                SSLCertificateKeyFile /etc/ssl/private/apache-selfsigned.key

                <FilesMatch "\.(cgi|shtml|phtml|php)$">
                                SSLOptions +StdEnvVars
                </FilesMatch>
                <Directory /usr/lib/cgi-bin>
                                SSLOptions +StdEnvVars
                </Directory>

                <FilesMatch "\.(cgi|shtml|phtml|php)$">
                                SSLOptions +StdEnvVars
                </FilesMatch>
                <Directory /usr/lib/cgi-bin>
                                SSLOptions +StdEnvVars
                </Directory>

        </VirtualHost>
</IfModule>

0 个答案:

没有答案