PHP表单未提交(等待localhost ...)

时间:2017-07-14 12:43:31

标签: php forms time upload

在这里查看一些答案,但似乎没有任何工作.. 我是PHP的新手,试图从jquery引导框对话框中的表单上传多个文件。

这是我的表格:

function dialogUpload() {
    bootbox.confirm({
        message:  '<form name="uploadForm" action="Control/upload.php" method="post" enctype="multipart/form-data"> '
                + '     Nome do objeto:<br />'
                + '     <input name="objectname" type="text"><br />'
                + '     <input type="hidden" name="MAX_FILE_SIZE" value="10000000">'
                + '     Objeto 3D(Formato <b>.dae</b>):<br />'
                + '     <input name="userfile[]" type="file" /><br />'
                + '     Imagem 2D do objeto(Formato <b>.png</b> ou <b>.jpg</b>) (<i>Opcional</i>):'
                + '     <input name="userfile[]" type="file" /><br />'
                + '     Comentário:<br />'
                + '     <textarea name="comment" rows="5" cols="75"></textarea>'
                + '</form>',
        buttons: {
            confirm: {
                label: 'Enviar Arquivo',
                className: 'btn-success'
            },
            cancel: {
                label: 'Cancelar',
                className: 'btn-danger'
            }
        },
        callback: function (result) {
            if(result){
                document.uploadForm.submit();
            }
        }
    });
}

并且继承我的PHP,它只是创建一个随机文件名并检查文件扩展名...而不是将文件上传到相应的文件夹。 使用XAMPP在Windows 10上运行(不知道它是否相关)

<?php
include '../Model/conexao.php';
include 'funcoes.php';


echo '<script>alert("Upload script started.");</script>';
$uploadIsOk = TRUE;

$imageUploaded = FALSE;

$targetObjectDirectory = "C:\xampp\htdocs\importaobjetos\uploads\objects";
$targetImageDirectory = "C:\xampp\htdocs\importaobjetos\uploads\images";

$fileName = createFileName($targetObjectDirectory);

$targetObjectFile = $targetObjectDirectory . basename($_FILES["userfile"][0]["name"]);
$targetObjectFileType = pathinfo($targetObjectFile, PATHINFO_EXTENSION);

if($_FILES["userfile"][1]["name"] != ""){
    $targetImageFile = $targetObjectDirectory . basename($_FILES["userfile"][1]["name"]);
    $targetImageFileType = pathinfo($targetImageFile,PATHINFO_EXTENSION);
    $imageUploaded = TRUE;
}


$errorMessage = '<script>alert("';
$successMessage = '<script>alert("';

checkExtensions();
replaceOriginalFileName();

if(!$uploadIsOk){
    $errorMessage = $errorMessage . 'Erros occoridos estão acima, upload não foi feito.';
    $errorMessage = $errorMessage . '");</script>';
    echo $errorMessage;
}
else{
    //Tudo certo, fazer upload

    if(move_uploaded_file($_FILES["userfile"][0]["tmp_name"], $targetObjectFile)){
        $successMessage = $successMessage . 'Upload do objeto foi feito com sucesso.\n';
        if($imageUploaded && move_uploaded_file($_FILES["userfile"][1]["tmp_name"], $targetImageFile))
            $successMessage = $successMessage . 'Upload da imagem foi feito com sucesso.\n';
    }

    $successMessage = $successMessage . '");</script>';
    echo $successMessage;
}


//Funcoes

function checkExtensions(){
    echo '<script>alert("checkExtensions");</script>';
    if($targetObjectFileType != "dae"){
        $uploadIsOk = FALSE;
        $errorMessage = $errorMessage . 'Formato invalido para o objeto, favor usar arquivos .dae\n';
    }

    if($imageUploaded){
        if($targetImageFileType != "jpg" && $targetImageFileType != "jpeg" && $targetImageFileType != "png"){
            $uploadIsOk = FALSE;
            $errorMessage = $errorMessage . 'Formato invalido para a imagem, favor usar arquivos .jpg, .jpeg ou .png\n';
        }
    }
}

function createFileName($targetObjectDirectory){
    $fileCreated = FALSE;
    echo '<script>alert("createFileName");</script>';
    while(!$fileCreated){
        $fileName = "";
        $size = mt_rand(5,9);
        $all_str = "abcdefghijlkmnopqrstuvxyzwABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
        for ($i = 0;$i <= $size;$i++){
            $fileName .= $all_str[mt_rand(0,61)];
        }

        $filePath = $targetObjectDirectory . $fileName . '.dae';

        if(checkIfExists($filePath))
            $fileCreated = TRUE;
    }

    return $fileName;
}

function checkIfExists($filePath){
    if(file_exists($filePath))
        return TRUE;
    else
        return FALSE;
}

function replaceOriginalFileName(){
    $targetObjectFile = $targetObjectDirectory . $fileName . '.' . $targetObjectFileType;
    if(imageUploaded)
        $targetImageFile = $targetImageDirectory . $fileName . '.' . $targetImageFileType;
    else
        $errorMessage = $errorMessage . 'Voce nao fez upload da imagem, será utilizada a imagem padrao.';
}

?>

我在php.ini中改变了一些事情,试图让它工作......:

file_uploads = On
upload_max_filesize = 10M
max_file_uploads = 20
post_max_size = 10M
max_input_time = 360

奇怪的是,它在max_input_time之后调用php脚本。然后它在脚本开始时回显警告,并给出错误

Fatal error: Maximum execution time of 360 seconds exceeded in C:\xampp\htdocs\importaobjetos\Control\upload.php on line 113
有人可以帮忙吗?

修改 Apache errors.log(来自上次审判)

[Fri Jul 14 10:34:29.219240 2017] [ssl:warn] [pid 5864:tid 664] AH01909: www.example.com:443:0 server certificate does NOT include an ID which matches the server name
[Fri Jul 14 10:34:29.275767 2017] [core:warn] [pid 5864:tid 664] AH00098: pid file C:/xampp/apache/logs/httpd.pid overwritten -- Unclean shutdown of previous Apache run?
[Fri Jul 14 10:34:29.332850 2017] [ssl:warn] [pid 5864:tid 664] AH01909: www.example.com:443:0 server certificate does NOT include an ID which matches the server name
[Fri Jul 14 10:34:29.354372 2017] [mpm_winnt:notice] [pid 5864:tid 664] AH00455: Apache/2.4.25 (Win32) OpenSSL/1.0.2j PHP/5.6.30 configured -- resuming normal operations
[Fri Jul 14 10:34:29.354372 2017] [mpm_winnt:notice] [pid 5864:tid 664] AH00456: Apache Lounge VC11 Server built: Dec 20 2016 13:02:04
[Fri Jul 14 10:34:29.354372 2017] [core:notice] [pid 5864:tid 664] AH00094: Command line: 'c:\\xampp\\apache\\bin\\httpd.exe -d C:/xampp/apache'
[Fri Jul 14 10:34:29.355874 2017] [mpm_winnt:notice] [pid 5864:tid 664] AH00418: Parent: Created child process 4944
[Fri Jul 14 10:34:29.754780 2017] [ssl:warn] [pid 4944:tid 632] AH01909: www.example.com:443:0 server certificate does NOT include an ID which matches the server name
[Fri Jul 14 10:34:29.929697 2017] [ssl:warn] [pid 4944:tid 632] AH01909: www.example.com:443:0 server certificate does NOT include an ID which matches the server name
[Fri Jul 14 10:34:29.953227 2017] [mpm_winnt:notice] [pid 4944:tid 632] AH00354: Child: Starting 150 worker threads.
[Fri Jul 14 10:34:42.508930 2017] [:error] [pid 4944:tid 1920] [client ::1:54421] PHP Notice:  Trying to get property of non-object in C:\\xampp\\htdocs\\importaobjetos\\index.php on line 152
[Fri Jul 14 10:34:42.509446 2017] [:error] [pid 4944:tid 1920] [client ::1:54421] PHP Notice:  Trying to get property of non-object in C:\\xampp\\htdocs\\importaobjetos\\index.php on line 162

当我尝试获取php_error_log时,它会给我“the system cannot find the path specified

1 个答案:

答案 0 :(得分:0)

根据链接WAMPServer phpMyadmin Maximum execution time of 360 seconds exceeded进行更改。你重新启动了wamp服务器了吗? 还是会出现同样的错误?

向我发送错误详情。