Nicedit upload images locally fails

你。 提交于 2019-12-09 07:33:32

问题


This is how I call the editor:

new nicEditor({
           buttonList : ['bold','italic','underline','upload'],
           iconsPath:'img/nicedit.png',
           uploadURI : 'http://server.com/integracion/files/nicUpload.php'
}).panelInstance(textareaId);

And the .php file exists ( and I the one in the Docs, and I updated the target paths )

/* I want them here http://server.com/integracion/files/uploads/ so... */   
    define('NICUPLOAD_PATH', './uploads'); // Set the path (relative or absolute) to
                                              // the directory to save image files                  
    define('NICUPLOAD_URI', '/uploads');   // Set the URL (relative or absolute) to
                                              // the directory defined above

But I on response when upload completes (and of corse an alert from nicedit..)

<script>
        try {
            top.nicUploadButton.statusCb({"error":"Invalid Upload ID"});
        } catch(e) { alert(e.message); }
    </script>

what am I missing?

-EDIT

I think the problem might be in the php file:

$id = $_POST['APC_UPLOAD_PROGRESS'];  /* APC is installed and enabled */
if(empty($id)) {
    $id = $_GET['id'];
}

回答1:


FINAL EDIT:

I have managed to make this work!

Here is an working example:
http://simplestudio.rs/yard/nicedit/

Uploaded images are going to be stored here:
http://simplestudio.rs/yard/nicedit/images/

And here is the whole code, just unpack it and put on your server, mainly I needed to adjust nicEdit.js because it had some issues.
http://simplestudio.rs/yard/nicedit/nicedit.rar

Just make your code with that js file and by looking at my example, it will work :)

  • Also you need to have php APC installed so that this script can work:
    http://php.net/manual/en/apc.installation.php

If you by any mean have some problems I am here to solve it.

  • I will not delete this example on my server so that everybody who have this issue can freely download it...



回答2:


The code responsible for image upload is the method uploadFile, it is looking for uploadURI option parameter.

You will need to modify onUploaded event handler to parse your custom response instead of the imgur's one (sample). By default it expects at least {"upload": { "links": {"original": "http://..."}, "image": {"width": "123" } }}.

I'm sorry but I can't help with the FormData() handling server side with PHP.

For more information you can try out the demo page on the nicEdit web site using Firebug or WebInspector to snoop the network requests, and, of course, the source code.



来源:https://stackoverflow.com/questions/12662062/nicedit-upload-images-locally-fails

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!