2017-10-11 6 views
0

nicEditor for textareaに関する問題があります。NicEdit画像はアップロードされましたが、エディタで空白の画像が表示されます

ローカルストレージイメージから画像をアップロードすると、フォルダにもデータベースにもアップロードされますが、テキストエリアには表示されません。 enter image description here

画像のテキストエディタでわかるように、空白の画像が表示されます。 私のコードは以下の通りです。

var nicUploadOptions = { 
     buttons : { 
      'upload' : {name : 'Upload Image', type : 'nicUploadButton'} 
     } 

    }; 
    var nicUploadButton=nicEditorAdvancedButton.extend({nicURI:"image.php" and more.. 
    nicEditors.registerPlugin(nicPlugin,nicUploadOptions); 

そしてPHPコードは

<?php 
//Check if we are getting the image 
if(isset($_FILES['image'])){ 
     //Get the image array of details 
     $img = $_FILES['image'];  
     //The new path of the uploaded image, rand is just used for the sake of it 
     $path = "upload/" . rand().$img["name"]; 
     //Move the file to our new path 
     move_uploaded_file($img['tmp_name'],$path); 
     //Get image info, reuiqred to biuld the JSON object 
     $data = getimagesize($path); 
     //The direct link to the uploaded image, this might varyu depending on your script location  
     $link = "http://$_SERVER[HTTP_HOST]"."/nicedit/".$path; 
     //Here we are constructing the JSON Object 
     $res = array("data" => array("link" => $link, "width" => $data[0], "height" => $data[1])); 
     //echo out the response :) 
     echo json_encode($res); 
} 
?> 

画像が正常にフォルダおよびデータベースにアップロードされます続くようです。

+1

コンソールを確認するか、imgを調べて返品内容を確認してください。 –

答えて

0

には、以下のSollution

line starting with nicURI:"http://api.imgur.com/2/upload.json" 
    Replace with 

    nicURI:"image.php" 

を見つけ、PHPコードは

<?php 
//Check if we are getting the image 
if(isset($_FILES['image'])){ 
     //Get the image array of details 
     $img = $_FILES['image'];  
     //The new path of the uploaded image, rand is just used for the sake of it 
     $path = "upload/" . rand().$img["name"]; 
     //Move the file to our new path 
     move_uploaded_file($img['tmp_name'],$path); 
     //Get image info, reuiqred to biuld the JSON object 
     $data = getimagesize($path); 
     //The direct link to the uploaded image, this might varyu depending on your script location  
     $link = "http://$_SERVER[HTTP_HOST]"."/nicedit/".$path; 
     //Here we are constructing the JSON Object 
     $res = array("data" => array("link" => $link, "width" => $data[0], "height" => $data[1]));       
        )); 
     //echo out the response :) 
     echo json_encode($res); 
} 
?> 

行われます!今すぐ何かをアップロードしようとすると、あなたのサーバーに直接行きます。

私は、http://manzzup.blogspot.com.br/2014/03/customize-nicedit-image-upload-to.htmlを受け取りました。

関連する問題