0% found this document useful (0 votes)
1K views

PHP - CodeIgniter Upload Image Through Tinymce - Stack Overflow

The document is a discussion thread on Stack Overflow about uploading images through TinyMCE within CodeIgniter. The original poster wants to be able to upload images through TinyMCE and have them display within the post text. Respondents suggest using a separate file upload field or writing a TinyMCE plugin to handle uploads, then saving the image names to the database and displaying them with the post. The poster is concerned about uploading multiple images and having them display nicely. Suggestions include using an iframe to upload images like AJAX and storing image names in the database to display with posts.

Uploaded by

Baskoro Sinelir
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
1K views

PHP - CodeIgniter Upload Image Through Tinymce - Stack Overflow

The document is a discussion thread on Stack Overflow about uploading images through TinyMCE within CodeIgniter. The original poster wants to be able to upload images through TinyMCE and have them display within the post text. Respondents suggest using a separate file upload field or writing a TinyMCE plugin to handle uploads, then saving the image names to the database and displaying them with the post. The poster is concerned about uploading multiple images and having them display nicely. Suggestions include using an iframe to upload images like AJAX and storing image names in the database to display with posts.

Uploaded by

Baskoro Sinelir
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

3/21/2016

phpCodeIgniteruploadimagethroughtinymceStackOverflow

StackOverflowisacommunityof4.7
millionprogrammers,justlikeyou,
helpingeachother.

signup

login

tour

help

JointheStackOverflowcommunityto:

Jointhemitonlytakesaminute:
Signup

Askprogramming
questions

Answerandhelp
yourpeers

Getrecognizedforyour
expertise

CodeIgniteruploadimagethroughtinymce
I'dlikesomehelpplease.IhavecreatedaformwithCodeIgniterwhereIcanwritepostsandwhatI'dliketodoistoaddthefunctionalitytoupload
image(s)forthispost.
AtthebeginningIthoughttoaddaninputfieldinmyformwhereIcanuploadfiles,soIcandisplaythemabovethecontent(text)atthefrontend,
butalthoughthisisaveryquickandeasysolution,maybenotsoflexible.SoIthoughttousethe'insert/editimage'buttonthattinymcehas.
IhaventdonethisbeforesohowcanIuploadanimageorimagesthroughtinymcesothattheyappearwithinthetextatthefrontend??
EDIT Hereismycode.
Thisismyview:
<?phpechoform_open_multipart();?>
<div>
<labelfor="title">Title*</label>
<?phpechoform_input('title',html_escape(set_value('title',$article>title)));
?>
</div>
<div>
<labelfor="file">Uploadimage</label>
<?phpechoform_upload('file');?>
</div>
<div>
<labelfor="body">Body*</label>//hasTinyMce
<?phpechoform_textarea('body',strip(set_value('body',$article>body)));?>
</div>
<div>
<?phpechoform_submit('save','Save');?>
</div>
<?phpechoform_close();?>

Thisismymodel:
publicfunctionsave($id=null){
$post_data=array(
'title'=>$this>input>post('title'),
'file'=>$this>input>post('file'),
'body'=>$this>input>post('body'),
);
returnparent::save($post_data,$id);
}

Thisisthecontroller:
publicfunctionarticle($id=null){
....
$this>form_validation>set_rules($this>article_model>rules);
//Processtheform
if($this>form_validation>run()==TRUE){
$this>article_model>save($id);
redirect('admin/article');
}
}
php codeigniter fileupload tinymce codeigniter2
editedNov3'13at9:15

askedNov3'13at9:00

Lykos
666

16

35

whatuhavetriedsofar.Sharesomecode.wecannotwritecompletecodeforyou.SureshKamrushiNov
3'13at9:02
Sorryforgotthat..pleasereviewthepostabove Lykos Nov3'13at9:16
responsivefilemanager.comyoucantrythisTinyMCEplugin.foruploadingimagesorfiles,it'sfreeforthe
meantime:)tomexsans Nov4'13at3:27
Thislooksquitecool!I'mplaningtodosomesmallchanges,sowhatIwanttodo,basicly,istoupload

http://stackoverflow.com/questions/19751325/codeigniteruploadimagethroughtinymce

1/4

3/21/2016

phpCodeIgniteruploadimagethroughtinymceStackOverflow

throughasecondaryformanimageto'uploads/articles'folderandtheninthemainformwiththetinymce
wheniclicktheinsertimagebuttontobrowsetheuploadsfolderandinserttheimagewithinthetext.CanI
dothatwiththisplugin??? Lykos Nov4'13at16:32

2Answers

Therearetwoapproachestothis.
YoueitherkeepanuploadfieldoutsideTinyMCEanduseajax/iframefileupload.
OR
WriteaTinyMCEpluginwithanabilitytouploadanimage.
Pleasenotethatbothoftheseapproachestakesomeefforttoimplement.
Asfarashandlingthefileontheserversideisconcerned,youcangothroughtheCodeigniter
Docs togetyoustarted.
answeredNov3'13at11:07

GladToHelp
3,089

12

38

youmeantohaveapluginthatwillusethefileuploadandtheimagemanipulationclasses??howcanido
this?? Lykos Nov3'13at11:58
TinyMCEhasit'sownwayofwritingpluginstinymce.com/wiki.php/API3:class.tinymce.Plugin.Youwillwant
onethatopensadialogbox,withanuploadbuttonandallowstheusertochooseanimageanduploadthe
image.Ofcourse,tohandletheuploadingitselfontheserver,youcoulduseimagemanipulationclass
offeredbycodeigniter.GladToHelpNov3'13at12:01
HowcanIdothisyousaid?isthereanytutorialavailableoranylinkthatshowshowtoembedthetinymce's
pluginwiththecodeigniter'simageclass??? Lykos Feb16'14at10:51

Inmyopinion,Ithinkthatyoushoulduseseparatefieldtouploadimagestoserverasthishelps
youcontrolthem,resize,determinefilenameanduploadpath
youcanuseform_open_multipart()Codeigniterfunctiontouploadfiles
thenyoucanmakeaDBtablefieldcalledimageandinserttheuploadedfilenametoit
thenretrievingthepostyoucan
<imgsrc="<?phpecho$post>image;?>"/>
<p><?phpecho$post>content?></p>
answeredNov3'13at9:07

Khashabawy
11

ThisiswhatIdecidedtodofirst,butwhatifinasinglepostIhavemorethanoneimages?ifIloopthrough
the<img>todisplaythemall,I'llhaveabanchofimagesandthenthetext,whichIdon'tthinkthatwilllook
nice.Isthereanywaytouploadanimagetotheserverthroughtinymceandcontrolthem,resizethemetc
etcthroughtheImagelibrarytoo?? Lykos Nov3'13at9:20
Nothereisnot:(Khashabawy Nov3'13at9:34
IalwaysusetheIframemethodtouploadfilesasiftheywereuploadedbyajaxandithinkthiswouldbe
usefulforyouKhashabawy Nov3'13at9:36

http://stackoverflow.com/questions/19751325/codeigniteruploadimagethroughtinymce

2/4

3/21/2016

phpCodeIgniteruploadimagethroughtinymceStackOverflow

http://stackoverflow.com/questions/19751325/codeigniteruploadimagethroughtinymce

3/4

3/21/2016

phpCodeIgniteruploadimagethroughtinymceStackOverflow

8.3kfollowers,43.4kquestions

rss

CodeIgniterisanopensourcePHPw ebdevelopment
framew orkcreatedbyEllisLabIncandithasbeenadoptedby
BritishColumbiaInstituteofTechnology.Theframew ork
implementsamodifiedversionoftheModelView Controller
designpattern.UsethistagforquestionsaboutCodeIgniter
classes,methods,functions,syntaxanduse.
frequent info topusers

http://stackoverflow.com/questions/19751325/codeigniteruploadimagethroughtinymce

4/4

You might also like