Sie sind auf Seite 1von 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

Das könnte Ihnen auch gefallen