最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - dropzoneJS - preview image in another element outside dropzone class - Stack Overflow

programmeradmin0浏览0评论

I'm using CodeIgniter, i've been searching for this part and no answer is what i want.
how to add preview image and file in another element of dropdownJS, let's call div#preview like this

<form action='upload' class='dropzone'>
    //dropzone usually add preview in here
</form>

<div id='preview'>
    //what i want image preview in here, so form is just for uploading
</div>

My goal is:
1. Preview image is in outside dropzone class
2. After refresh page, still displaying preview image
3. For displaying after refresh page, is it possible without saving filename in database?

I'm using CodeIgniter, i've been searching for this part and no answer is what i want.
how to add preview image and file in another element of dropdownJS, let's call div#preview like this

<form action='upload' class='dropzone'>
    //dropzone usually add preview in here
</form>

<div id='preview'>
    //what i want image preview in here, so form is just for uploading
</div>

My goal is:
1. Preview image is in outside dropzone class
2. After refresh page, still displaying preview image
3. For displaying after refresh page, is it possible without saving filename in database?

Share Improve this question asked Jun 15, 2016 at 7:03 Akhid LeoAkhid Leo 1252 silver badges9 bronze badges 1
  • You might want to share what you have tried so far :) – Fge Commented Jun 15, 2016 at 7:06
Add a ment  | 

1 Answer 1

Reset to default 5

Sorry my fault didn't read dropzonejs doc detailed,
The solution is just add setting

previewsContainer: //set to where element to display,

example :

Dropzone.autoDiscover = false;
var myDropzone = new Dropzone(".dropzone", {
    url: " some_upload_url ",
    acceptedFiles: "image/*",
    addRemoveLinks: true,
    previewsContainer: '#preview', //this will change preview to element selected
    etc etc
发布评论

评论列表(0)

  1. 暂无评论