富文本輸入框,NicEditxia

下載地址http://nicedit.com/index.php

上傳圖片功能有問題。

上傳圖片功能是通過上傳到nicUploadButton=nicEditorAdvancedButton.extend({nicURI:"http://api.imgur.com/2/upload.json"

可能由於網絡環境的原因,基本上上傳不了。

需要在本地搭建接收上傳圖片的後台。

需要在Apache httpd.conf中進行配置,另其接收超過3m的圖片。

需在nicEdit.js中修改

var nicUploadButton=nicEditorAdvancedButton.extend({nicURI:"imgupload.php"

imgupload.php後台代碼

<?php
//Check if we are getting the image
if(isset($_FILES['image'])){
        //Get the image array of details
        $parentpath=dirname(__FILE__);
        $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 = $path;
        //Here we are constructing the JSON Object
        $res = array("upload" => array(
                                "links" => array("original" => $link),
                                "image" => array("width" => $data[0],
                                                 "height" => $data[1]
                                                )                              
                    ));
        //echo out the response :)
        echo json_encode($res);
}
?>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值