File Uploading for CKEditor using CodeIgniter


I know, I know that I haven’t uploaded the source code of my simple project, Blog Manager, yet to github. I have already created the repository, though. This is just a notification update on Blog Manager.

As my boss really planned to make it a wordpress like text editor when adding a post, so I work on CKEditor, a great editor I must say, but quite tiring to create the file browser (it’s just me I think). For now, I have also added the Blog Manager category on this blog, Various Talks.

AS for your information, to create simple upload dialog on CKEditor, you can use the code chunk below for PHP.

PS. I was inspired by this post. So I lazily changed it for CodeIgniter. Yeah because I’d rather change than rethink about the algorithm and read a long example. LOL

public function addphoto($blogID){
	$this->load->model('BlogModel'); // the model that communicate with blog

	$config['upload_path'] = './uploads/';
	$config['allowed_types'] = 'gif|jpg|jpeg|png';
	$config['overwrite'] = FALSE;
	$this->load->library('upload');


	$funcNum = $this->input->get('CKEditorFuncNum'); //$_GET['CKEditorFuncNum']
	$this->upload->initialize($config);
		
	if (!$this->upload->do_upload('upload')){ // upload the file, 'upload' is the name of the field from CKEditor
		 // failed upload
		$message = "Upload failed on blog manager server.";
		$url = '';
	
	}else{ // success copy to wp server
		$upload_result = base_url() . 'uploads/'. $this->upload->data()['file_name'];
		$upload_name = $this->upload->data()['file_name'];

		// after finished uploading, it will receive a URL
		$url = $this->BlogModel->UploadImage($blogID, $upload_result, $upload_name); 

		$message = 'Upload success!';
	}
	echo "<script type='text/javascript'>window.parent.CKEDITOR.tools.callFunction($funcNum, '$url', '$message');</script>";
}

Feel free to notify me if you’re interested in this.

Be free to visit it in here!

Advertisements

Blog Manager


So, I was working on this PHP project as I have told you earlier in my post earlier.

It was called as Blog Manager. It is not really complete. I planned to put it in my git repository. I also created the wordpress plugin so that my app can operate well with WordPress.

After I reach to put both Blog Manager web app and Blog Manager WordPress plugin in my git repo, I will continue to add WP tags in the Blog Manager, and extend it to other PHP CMS like Joomla.

If you are interested, come to the git repository. 🙂

Be free to visit it in here!

PHP yeay!


Hello world!

Well, I am back to PHP! After a long time I haven’t used this, I am back again to PHP! So, I am working on a WordPress plugin.

It will allow the user to post through another web. Well, it is intended for a digital agencies, not for really commercial use. I will keep posting on it as the project grows.

C ya!

PS. Any suggestion about flexible and easy to use ASP.NET CMS is most welcome 😀

When You See It!


Hi I’m back again with my posts, this time I am away from programming post. Well, I have some programming posts to share, but I will do it later (read: procrastinating).

Last night, something interested me. My friend had a rumbling tummy but it was aching so bad, too. He asked me to accompany him looking for a chicken porridge. So after we arrived at the place to buy it. The place was next to a rather well-funded cafe with quite rich visitors. Somehow my sight fell on an old man selling a LED-lighted souvenir. It was 11 PM and this old man, probably 50 or 60 or more, was out there, on the street, selling the souvenir with no one paying attention. I didn’t really know what the money is for. What I knew is that old man is trying as hard as he can to survive.

The first conclusion that I got that time is as follows. As a Christian, I was taught if I can help people but I didn’t do anything about it, then I am sinned. So, I am sinned. I really do. I didn’t do anything about him, but because of it, I realize something. All these times, I spend my money on unimportant stuffs, like games, junk foods, entertainment, and others that I don’t really need. I realize that those money can help him, I should have helped him. Instead of wasting my money. I am really sorry about that, and I promised to change.

The second conclusion that I got after I got the first is as follows. I live in Jakarta. Here there is so many fribble. Wait, it is not appropriate. They should be called as scallywags or rascals! They get into public bus, shouting and disturbing people, telling that the government did not do anything about them, and asking for money. They blame on other people while they do nothing but keep asking. They say that they can’t learn anything but there is so many free schools. They say that they can’t do any job while the mayor pays anyone who works as scavengers daily. They keep complaining while if they look on that old man, he had no certificate, he had no power, he had only will, and spirit. I believe if they are the same age, that old man will be more successful than those rascals!

The point is, remember to save your money. It is better to use it to help others rather than spending it for some fun. Never ever blame others or your environment because of your incapability in shaping your life. It is just you that have little spirit and little will to do anything you want.