Php - CodeIgniter Upload Image Through Tinymce - Stack Overflow

December 23, 2018 | Author: Baskoro Sinelir | Category: Php, Ajax (Programming), Html Element, Computer File, Software Development
Share Embed Donate

Short Description




php - CodeIg ni ni te ter upl oa oad i ma mag e thr ou oug h ti ny nymce - Stack Over flfl ow ow sign sig n up

Stack Overflow is a community of 4 .7 million programmers, just like you, helping each other.

log lo g in

tour to ur

help he lp


Join the Stack Overflow community to:

Join them; it only takes a minute:  Ask programming programming questions

Sign up

 Answer and help your peers

Get recognized for your  expertise

CodeIgniter upload image through tinymce I'd like some help please. I have created a form with CodeIgniter where I can write posts and what I 'd like to do is to add the functionality to upload image(s) for this post.  At the beginni beginning ng I thought thought to add an input field in my form where I can upload files, files, s o I can display them above above the content (text) (text) at the front end, end, but although this is a very quick and easy solution, may be not so flexible. So I thought to use the 'insert/edit image' button that tinymce has. I haven’t done this before so how can I upload an image or images through tinymce so that they appear within the text at the front-end?? EDIT  Here is my code. This is my view: for= for ="title">Title * echo form_input( ' title', html_escape(set_value('title' 'title', html_escape(set_value('title', , $article‐>title)));

for= for ="file">Upload image echo form_upload( ' file'); ?> 'file');

for= for ="body">Body *   // has TinyMce echo form_textarea( form_textarea('body' 'body', , strip(set_value('body' strip(set_value('body', , $article‐>body))); ?>

echo form_submit( ' save', 'Save' 'save', 'Save'); ); ?> form_close(); ?>

This is my model: public function  save($id = null){

$post_data = array( 'title'  'title'   => $this‐>input‐>post('title' 'title'), ), 'file'  'file'   => $this‐>input‐>post('file' 'file'), ), 'body'  'body'   => $this‐>input‐>post('body' 'body'), ), ); return   parent::save($post_data, $id);


This is the controller: public function  article($id = null ){




$this‐>form_validation‐>set_rules($this‐>article_model‐>rules);  // Process the form if   ($this‐>form_validation‐>run() == TRUE) { $this‐>article_model‐>save($id); redirect('admin/article'); }

    } php

codei co deigni gnite terr

filefi le-upl upload oad

tiny ti nymce mce

codei co deigni gnitter er-2 -2 edited Nov 3 '13 at 9:15

asked Nov 3 '13 at 9:00

Lykos 666   2



what u have tried so far. Share some code. we can not write complete code for you. – Suresh Kamrushi Kamrushi Nov  Nov 3 '13 at 9:02 Sorry forgot that.. please review the post above –  Lykos Nov 3 '13 at 9:16 you can try this TinyMCE plugin. for uploading images or files, it's free for the mean time :)  – tomexsans tomexsans   Nov 4 '13 at 3:27 This looks quite cool! I'm planing to do do some small changes, so what what I want to do, do, basicly, is to upload

http://stackover fl ue uesti ons/19751325/codei g ni ter - upl oad- i mag e- thr oug hh- ti nymce



php - CodeIg ni ter upl oad i mag e thr oug h ti nymce - Stack Over fl ow

through a secondary form an image to 'uploads/articles' folder and then in the main form with the tinymce when i click the insert image button to browse the uploads folder and insert the image within the text. Can I do that with this plugin??? –  Lykos   Nov 4 '13 at 16:32

2 Answers

There are two approaches to this. You either keep an upload field outside TinyMCE and use ajax/iframe file upload. OR rite a TinyMCE plugin with an ability to upload an image. Please note that both of these approaches take some effort to implement.  As far as handling the file on the server side is concerned, you can go through the Codeigniter  Docs to get you started. answered Nov 3 '13 at 11:07

Glad To Help 3,089   1



you mean to have a plugin that will use the file upload and the image manipulation classes?? how can i do this?? –  Lykos Nov 3 '13 at 11:58 TinyMCE has it's own way of writing plugins .You will want one that opens a dialog box, with an upload button and allows the user to choose an image and upload the image. Of course, to handle the uploading itself on the server, you could use image manipulation class offered by codeigniter.  – Glad To Help Nov 3 '13 at 12:01 How can I do this you said? is there any tutorial available or any link that shows how to embed the tinymce's plugin with the codeigniter's image class???  –  Lykos Feb 16 '14 at 10:51

In my opinion , I think that you should use separate field to upload images to server as this helps you control them , resize , determine file name and upload path you can use form_open_multipart() Codeigniter function to upload files hen you can make a DB table field called image and insert the uploaded file name to it hen retrieving the post you can
View more...


Copyright ©2017 KUPDF Inc.