2017-04-17 3 views
0

私は自分のサイト上で実装するManually Trigger Uploads & Edit File Namesデモをしようとしていたが失敗し、すべてが素晴らしい作品が、私はファイルをアップロードしようとしたとき、私は、コンソールに次のようだ:ファインアップローダーBitnamiのwampstackのアップロードは

responseText = {"error":"Server error. Uploads directory isn't writable","uploadName":null}

を私はすでに他の類似の質問を検索していますが、どれも私のために働いていないようですが、回答の中には{成功:真実}の話がありますが、その意味や理解がわかりません。デモコードは成功しません:真のプロパティ。

また、このコマンドで画像(/ project-root/tmp)をアップロードするフォルダのアクセス許可を設定しようとしました:cacls apache2\htdocs\project\tmp /t /e /g everyone:fしかし、それは動作しませんでした。プラグインは非常に良いですが、私は彼らがドキュメントにもっと多くの例を入れるべきだと思います。どんな助けもありがとう。ここで

は私のテンプレートです:

 <div class="qq-uploader-selector qq-uploader" qq-drop-area-text="Drop files here"> 
     <div class="qq-total-progress-bar-container-selector qq-total-progress-bar-container"> 
      <div role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100" class="qq-total-progress-bar-selector qq-progress-bar qq-total-progress-bar"></div> 
     </div> 
     <div class="qq-upload-drop-area-selector qq-upload-drop-area" qq-hide-dropzone> 
      <span class="qq-upload-drop-area-text-selector"></span> 
     </div> 
     <div class="buttons"> 
      <div class="qq-upload-button-selector qq-upload-button"> 
       <div>Select files</div> 
      </div> 
     </div> 
     <span class="qq-drop-processing-selector qq-drop-processing"> 
      <span>Processing dropped files...</span> 
      <span class="qq-drop-processing-spinner-selector qq-drop-processing-spinner"></span> 
     </span> 
     <ul class="qq-upload-list-selector qq-upload-list" aria-live="polite" aria-relevant="additions removals"> 
      <li> 
       <div class="qq-progress-bar-container-selector"> 
        <div role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100" class="qq-progress-bar-selector qq-progress-bar"></div> 
       </div> 
       <span class="qq-upload-spinner-selector qq-upload-spinner"></span> 
       <img class="qq-thumbnail-selector" qq-max-size="100" qq-server-scale> 
       <span class="qq-upload-file-selector qq-upload-file"></span> 
       <span class="qq-edit-filename-icon-selector qq-edit-filename-icon" aria-label="Edit filename"></span> 
       <input class="qq-edit-filename-selector qq-edit-filename" tabindex="0" type="text"> 
       <span class="qq-upload-size-selector qq-upload-size"></span> 
       <button type="button" class="qq-btn qq-upload-cancel-selector qq-upload-cancel">Cancel</button> 
       <button type="button" class="qq-btn qq-upload-retry-selector qq-upload-retry">Retry</button> 
       <button type="button" class="qq-btn qq-upload-delete-selector qq-upload-delete">Delete</button> 
       <span role="status" class="qq-upload-status-text-selector qq-upload-status-text"></span> 
      </li> 
     </ul> 

     <dialog class="qq-alert-dialog-selector"> 
      <div class="qq-dialog-message-selector"></div> 
      <div class="qq-dialog-buttons"> 
       <button type="button" class="qq-cancel-button-selector">Close</button> 
      </div> 
     </dialog> 

     <dialog class="qq-confirm-dialog-selector"> 
      <div class="qq-dialog-message-selector"></div> 
      <div class="qq-dialog-buttons"> 
       <button type="button" class="qq-cancel-button-selector">No</button> 
       <button type="button" class="qq-ok-button-selector">Yes</button> 
      </div> 
     </dialog> 

     <dialog class="qq-prompt-dialog-selector"> 
      <div class="qq-dialog-message-selector"></div> 
      <input type="text"> 
      <div class="qq-dialog-buttons"> 
       <button type="button" class="qq-cancel-button-selector">Cancel</button> 
       <button type="button" class="qq-ok-button-selector">Ok</button> 
      </div> 
     </dialog> 
    </div> 

マイJavascriptを:

var manualUploader = new qq.FineUploader({ 
    element: document.getElementById('fine-uploader-manual-trigger'), 
    template: 'qq-template-manual-trigger', 
    request: { 
     endpoint: ''+ENDPOINT.path+'/endpoint.php' 
    }, 
    autoUpload: true, 
    debug: true 
}); 

と(ほとんどofficial githubのと同じである)私のendpoint.php:

<?php 

/** 
* PHP Server-Side Example for Fine Uploader (traditional endpoint handler). 
* Maintained by Widen Enterprises. 
* 
* This example: 
* - handles chunked and non-chunked requests 
* - supports the concurrent chunking feature 
* - assumes all upload requests are multipart encoded 
* - supports the delete file feature 
* 
* Follow these steps to get up and running with Fine Uploader in a PHP environment: 
* 
* 1. Setup your client-side code, as documented on http://docs.fineuploader.com. 
* 
* 2. Copy this file and handler.php to your server. 
* 
* 3. Ensure your php.ini file contains appropriate values for 
* max_input_time, upload_max_filesize and post_max_size. 
* 
* 4. Ensure your "chunks" and "files" folders exist and are writable. 
* "chunks" is only needed if you have enabled the chunking feature client-side. 
* 
* 5. If you have chunking enabled in Fine Uploader, you MUST set a value for the `chunking.success.endpoint` option. 
* This will be called by Fine Uploader when all chunks for a file have been successfully uploaded, triggering the 
* PHP server to combine all parts into one file. This is particularly useful for the concurrent chunking feature, 
* but is now required in all cases if you are making use of this PHP example. 
*/ 

// Include the upload handler class 
require_once "handler.php"; 


$uploader = new UploadHandler(); 

// Specify the list of valid extensions, ex. array("jpeg", "xml", "bmp") 
$uploader->allowedExtensions = array(); // all files types allowed by default 

// Specify max file size in bytes. 
$uploader->sizeLimit = null; 

// Specify the input name set in the javascript. 
$uploader->inputName = "qqfile"; // matches Fine Uploader's default inputName value by default 

// If you want to use the chunking/resume feature, specify the folder to temporarily save parts. 
$uploader->chunksFolder = "chunks"; 

$method = get_request_method(); 

// This will retrieve the "intended" request method. Normally, this is the 
// actual method of the request. Sometimes, though, the intended request method 
// must be hidden in the parameters of the request. For example, when attempting to 
// delete a file using a POST request. In that case, "DELETE" will be sent along with 
// the request in a "_method" parameter. 
function get_request_method() { 
    global $HTTP_RAW_POST_DATA; 

    if(isset($HTTP_RAW_POST_DATA)) { 
     parse_str($HTTP_RAW_POST_DATA, $_POST); 
    } 

    if (isset($_POST["_method"]) && $_POST["_method"] != null) { 
     return $_POST["_method"]; 
    } 

    return $_SERVER["REQUEST_METHOD"]; 
} 

if ($method == "POST") { 
    header("Content-Type: text/plain"); 

    // Assumes you have a chunking.success.endpoint set to point here with a query parameter of "done". 
    // For example: /myserver/handlers/endpoint.php?done 
    if (isset($_GET["done"])) { 
     $result = $uploader->combineChunks("files"); 
    } 
    // Handles upload requests 
    else { 

     // Call handleUpload() with the name of the folder, relative to PHP's getcwd() 
     $result = $uploader->handleUpload("tmp"); 

     // To return a name used for uploaded file you can use the following line. 
     $result["uploadName"] = $uploader->getUploadName(); 

    } 

    echo json_encode($result); 
} 
// for delete file requests 
else if ($method == "DELETE") { 
    $result = $uploader->handleDelete("files"); 
    echo json_encode($result); 
} 
else { 
    header("HTTP/1.0 405 Method Not Allowed"); 
} 

?> 

答えて

0

問題はフォルダのパスでした:

// Call handleUpload() with the name of the folder, relative to PHP's getcwd() 
     $result = $uploader->handleUpload("tmp") 

コメントは、PHPのgetcwd()に関連していますが、その関数をエコーすると、ルートプロジェクトが得られるので、最後には、フォルダパスはendpoint.phpファイルの相対位置になります。私はフォルダパスに注意して同じ問題に直面している場合。ここで

私の作業endpoint.phpです:

<?php 

// Include the upload handler class 
require_once "handler.php"; 


$uploader = new UploadHandler(); 

// Specify the list of valid extensions, ex. array("jpeg", "xml", "bmp") 
$uploader->allowedExtensions = array(); // all files types allowed by default 

// Specify max file size in bytes. 
$uploader->sizeLimit = null; 

// Specify the input name set in the javascript. 
$uploader->inputName = "qqfile"; // matches Fine Uploader's default inputName value by default 

// If you want to use the chunking/resume feature, specify the folder to temporarily save parts. 
$uploader->chunksFolder = "../../uploads"; 

$method = get_request_method(); 

// This will retrieve the "intended" request method. Normally, this is the 
// actual method of the request. Sometimes, though, the intended request method 
// must be hidden in the parameters of the request. For example, when attempting to 
// delete a file using a POST request. In that case, "DELETE" will be sent along with 
// the request in a "_method" parameter. 
function get_request_method() { 
    global $HTTP_RAW_POST_DATA; 

    if(isset($HTTP_RAW_POST_DATA)) { 
     parse_str($HTTP_RAW_POST_DATA, $_POST); 
    } 

    if (isset($_POST["_method"]) && $_POST["_method"] != null) { 
     return $_POST["_method"]; 
    } 

    return $_SERVER["REQUEST_METHOD"]; 
} 

if ($method == "POST") { 
    header("Content-Type: text/plain"); 

    // Assumes you have a chunking.success.endpoint set to point here with a query parameter of "done". 
    // For example: /myserver/handlers/endpoint.php?done 
    if (isset($_GET["done"])) { 
     $result = $uploader->combineChunks("../../uploads"); 
    } 
    // Handles upload requests 
    else { 

     // Call handleUpload() with the name of the folder, relative to PHP's getcwd() 
     $result = $uploader->handleUpload("../../uploads"); //this folder was created in the root project, at the same level as wp-content 

     // To return a name used for uploaded file you can use the following line. 
     $result["uploadName"] = $uploader->getUploadName(); 

    } 

    echo json_encode($result); 
} 
// for delete file requests 
else if ($method == "DELETE") { 
    $result = $uploader->handleDelete("../../uploads"); 
    echo json_encode($result); 
} 
else { 
    header("HTTP/1.0 405 Method Not Allowed"); 
} 

?> 
関連する問題