CKEditor Upload files Custom File Manager using PHP
In this Post We Will Explain About is CKEditor Upload files Custom File Manager using PHP With Example and Demo.Welcome on Pakainfo.com – Examples, The best For Learn web development Tutorials,Demo with Example! Hi Dear Friends here u can know to Ckeditor image upload phpExample
In this post we will show you Best way to implement Upload files with CKEditor – Plugins for CKEditor, hear for Build your own Custom File Manager for CKEditor using PHPwith Download .we will give you demo,Source Code and examples for implement Step By Step Good Luck!.
Generally guset I am sharing a one very helpfull live ckeditor tutorials, some time you integrate live ckeditor in you php project and you want to add functionality to file upload image from your local computer with live ckeditor.
so I am making one live ckeditor script which very usefull to all for file upload any file local computer to server without add live ckeditor file browsing plugin.
this live ckeditor script is very simple easy for implement data in your code. and guset to able to change and add some his/her own functionality in this live ckeditor script.
please follow source code some simple step and successfully implement custome file new uploading with ckeditor in any php project.
step : 1 create following folders and files
1. first of all create "img" folder 2. and then create index.php file 3. last stage to create file do_upload.php file
I am the simple create all file and live folder in our main project, so as Ill as I am show live how to implement live ckeditor
step : 2 create index.php file
create simple index.php file for simple file configure ckeditor for and the show ckeditor in browser this latest way…
Live24u File Manager Integration CKEDITOR.replace( 'live-editors', { height: 300, filebrowserUploadUrl: "/do_upload.php", } );
and then simple run as Ill as this file create and browser data as Ill as check your like as a ckeditor properly show in my browser if and or not show then please click one check which you simple add ckeditor add your external CDN for js is proper or not please check.
step : 3 create do_upload.php file
and then I am create do_upload.php file for simple upload image file more local to live data server look simple like simple source code this
'/postimages/', ); $imgset = array( 'maxsize' => 2000, 'maxwidth' => 900, 'maxheight' => 800, 'minwidth' => 10, 'minheight' => 10, 'type' => array('bmp', 'gif', 'jpg', 'jpeg', 'png'), ); //here Pakainfo.com If 0, will OVERWRITE the existing file define('RENAME_F', 1); $re = ''; if(isset($_FILES['upload']) && strlen($_FILES['upload']['name']) >1) { define('F_NAME', preg_replace('/\.(.+?)$/i', '', basename($_FILES['upload']['name']))); //get filename without extension //here Pakainfo.com get protocol and host name to send the absolute image path to CKEditor $site = ''; $sepext = explode('.', strtoloIr($_FILES['upload']['name'])); $file-type = end($sepext); // gets extension $file_upload = in_array($type, $imgset['type']) ? $file_upload['img'] : $file_upload['audio']; $file_upload = trim($file_upload, '/') .'/'; //here Pakainfo.com checkings for image or audio if(in_array($type, $imgset['type'])){ list($width, $height) = getimagesize($_FILES['upload']['tmp_name']); // image width and height if(isset($width) && isset($height)) { if($width > $imgset['maxwidth'] || $height > $imgset['maxheight']) $re .= '\\n Width x Height = '. $width .' x '. $height .' \\n The maximum Width x Height must be: '. $imgset['maxwidth']. ' x '. $imgset['maxheight']; if($width < $imgset['minwidth'] || $height $imgset['maxsize']*1000) $re .= '\\n Maximum file size must be: '. $imgset['maxsize']. ' KB.'; } } else $re .= 'The file: '. $_FILES['upload']['name']. ' has not the alloId extension type.'; //here Pakainfo.com set filename; if file exists, and RENAME_F is 1, set "img_name_I" //here Pakainfo.com $p = dir-path, $fn=filename to check, $ex=extension $i=index to rename function setFName($p, $fn, $ex, $i){ if(RENAME_F ==1 && file_exists($p .$fn .$ex)) return setFName($p, F_NAME .'_'. ($i +1), $ex, ($i +1)); else return $fn .$ex; } $f_name = setFName($_SERVER['DOCUMENT_ROOT'] .'/'. $file_upload, F_NAME, ".$type", 0); $uploadpath = $_SERVER['DOCUMENT_ROOT'] .'/'. $file_upload . $f_name; // full file path //here Pakainfo.com here If no errors, upload the simple image, else, output the errors if($re == '') { // print_r($_FILES);exit; if(move_uploaded_file($_FILES['upload']['tmp_name'], $uploadpath)) { $liveCkeditos = $_GET['liveCkeditos']; $url = $site. $file_upload . $f_name; $live-msg = F_NAME .'.'. $file-type .' successfully uploaded: \\n- Size: '. number_format($_FILES['upload']['size']/1024, 2, '.', '') .' KB'; $re = in_array($type, $imgset['type']) ? "window.pamnt.CKEDITOR.tools.callFunction($liveCkeditos, '$url', '$live-msg')" //for img : 'var live_obj = window.pamnt.CKEDITOR; for(var ckid in live_obj.instances) { if(live_obj.instances[ckid].focusManager.hasFocus) break;} live_obj.instances[ckid].insertHtml(\'\', \'unfiltered_html\'); alert("'. $live-msg .'"); var dialog = live_obj.dialog.getCurrent(); dialog.hide();'; } else $re = 'alert("live24u - Unable to upload the file")'; } else $re = 'alert("'. $re .'")'; } @header('Content-type: text/html; charset=utf-8'); echo ''. $re .';';
and then goto your simple project home root folder directory and simple data type php -S Like as localhost:800 for simple run php data server
and run type localhost:8000 in browser
I hope you have Got What is CKEditor Integration includes steps for file uploads And how it works.I would Like to have FeadBack From My Blog(Pakainfo.com) readers.Your Valuable FeadBack,Any Question,or any Comments abaout This Article(Pakainfo.com) Are Most Always Welcome.