2017-07-14 44 views
0

在這裏查看一些答案,但似乎沒有任何工作.. 我是新來的PHP,並嘗試從jQuery的Bootbox對話框內的窗體上傳多個文件。 。PHP表單不提交(等待本地主機...)

這裏是我的形式:

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,它只是創建一個隨機文件名,並檢查文件擴展名......不是把文件上傳到相應的文件夾。 運行在Windows 10,與XAMPP(不知道這是否是相關的)

<?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 

好奇的是,它調用PHP腳本只是max_input_time..then後回聲對劇本的beggining警報,並給出了錯誤

Fatal error: Maximum execution time of 360 seconds exceeded in C:\xampp\htdocs\importaobjetos\Control\upload.php on line 113 

有人能幫忙嗎?

編輯: 阿帕奇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

+0

什麼是'max_execution_time'?在你的** php.ini **中。可能是你正在嘗試上傳需要時間的大文件。設置'max_execution_time'爲'0'然後嘗試 –

+0

參考此鏈接 - https://stackoverflow.com/questions/29916516/wampserver-phpmyadmin-maximum-execution-time-of-360-seconds-exceeded可能會有所幫助。 – KMS

+0

@ B.Desai做到了,仍然沒有工作......並且文件是200kb – alvarosps

回答

0

做的修改按鏈接WAMPServer phpMyadmin Maximum execution time of 360 seconds exceeded。你重新啓動了wamp服務器嗎? 還是會出現同樣的錯誤?

給我發送錯誤的詳細信息。

+0

如何獲取錯誤詳細信息?我得到了唯一的錯誤很多時間後,它是最大的執行時間... 我使用XAMPP,而不是WAMP,它沒有phpmyadmin.config文件..但設置是相似的,並作出了改變,並仍然不工作.. @ KMS – alvarosps

+0

編輯與錯誤日誌的帖子... – alvarosps