I was stugling with filemanager. I was looking for exactly code, so I can understand how it works! But I couldn't find. But now it is very easy and simple for me. I thought it could help some others.
You can find this codes from this link
if you install this plugin to your moodle, link1 will show you the page to upload the images and link2 will show the uploaded images.
I tried to make it simple; so there should not be any difficulty to understand for anyone who have idea of php code.