1

Topic: Database Operation Upon Clicking on Any MC Filemanager Button

HI ALL,

I NEED A FILE MANAGER FOR MY ASP.NET MVC APPLICATION. AFTER LOOKING AT DIFFERENT FILE MANAGER MC LOOKED PROMISING TO ME.
BUT I NEED TO CLARIFY SOMETHING BEFORE I  GO FOR MC FILE MANAGER. CURRENTLY I AM SAVING THE PATH AND USER NAME INSIDE A DATABASE TABLE WHEN FILE UPLOADED BY A USER. I SAW THE UPLOADING OF MC FILE MANAGER IS QUITE STRAIGHT FORWARD. SO IS IT POSSIBLE TO RUN A QUERY WHENEVER WE CLICK ON A FILE MANAGER BUTTON(FOR EXAMPLE UPLOAD,DELETE,CREATE)? HOW DO GET THE FOLDER NAME/ID THAT THE FILE IS BEING UPLOADED?

PLEASE UPDATE ME WITH  THESE INFO ASAP AS I NEED TO MAKE A QUICK CHOICE.

THANKS,
QAMAR

2

Re: Database Operation Upon Clicking on Any MC Filemanager Button

Yes, we have a onFileAction event that fires when a files are added, removed, updated, renamed, folders created, removed etc.

Best regards,
Spocke - Main developer of TinyMCE

3

Re: Database Operation Upon Clicking on Any MC Filemanager Button

THANKS SPOCKE FOR UR PROMPT REPLY. ONE MORE REQUEST CAN YOU PROVIDE ME AN EXAMPLE OF onFileAction EVENT EXECUTION?
THANKS AGAIN

4

Re: Database Operation Upon Clicking on Any MC Filemanager Button

The onFileAction event looks something like:

function onFileAction(&$man, $action, $file1, $file2) {
        if ($action == ADD_ACTION) {
             echo "File name:" . $file1->getName();
        }

    return true;
}

I think the capslock day ended 5 days ago.

Best regards,
Spocke - Main developer of TinyMCE

5

Re: Database Operation Upon Clicking on Any MC Filemanager Button

here is another question, how do i get the name of the folder in which file is being uploaded?
is it possible to get the file name which is being uploaded?
my scenario is while uploading a file i need to upload the file, upon successful upload i need take the filename and folder name in which the file has been uploaded and create a database record.
is it achievable?

6

Re: Database Operation Upon Clicking on Any MC Filemanager Button

You can get the parent by:
$file1->getParent();

The code I posted earlier will show the name. Just the code snippets I added here and it should work.

Best regards,
Spocke - Main developer of TinyMCE

7

Re: Database Operation Upon Clicking on Any MC Filemanager Button

Still your reply does not answer my database scenario?

8

Re: Database Operation Upon Clicking on Any MC Filemanager Button

if anyone can help me out with this problem will be highly appreciated......

"In my system while uploading, deleting or moving file , i want to save the filename, foldername, and filepath to the database and then do the operation in the server physically."

Have anyone come across such kind of scenario? Is it achievable by MCFileManager? If anyone has some initialization code on this please update me as  i need to choose file manager very quickly.

9

Re: Database Operation Upon Clicking on Any MC Filemanager Button

You can write a plugin and wait for the onFileAction event and handle it something like this:

function onFileAction(&$man, $action, $file1, $file2) {
    if ($action == ADD_ACTION) {
        echo "File added: name=" . $file1->getName() . ", path: " . $file1->getAbsolutePath() . ", parent: " . $file1->getParent();
    }

    if ($action == DELETE_ACTION) {
        echo "File added: name=" . $file1->getName() . ", path: " . $file1->getAbsolutePath() . ", parent: " . $file1->getParent();
    }

    if ($action == RENAME_ACTION) {
        echo "File moved: from name=" . $file1->getName() . ", from path: " . $file1->getAbsolutePath() . ", from parent: " . $file1->getParent();
        echo "File moved: to name=" . $file2->getName() . ", to path: " . $file2->getAbsolutePath() . ", to parent: " . $file2->getParent();
    }

    return true;
}

This should be enough information for most PHP developers. So you just need to add the SQL queries etc to insert/update the database depending on the action that happened. Check the filemanager/plugin/_Template directory for a baseline plugin.

Best regards,
Spocke - Main developer of TinyMCE

10

Re: Database Operation Upon Clicking on Any MC Filemanager Button

is it possible to load the files inside the file manager based on the file path saved in the database?

11

Re: Database Operation Upon Clicking on Any MC Filemanager Button

That is a bit more tricky the current implementation doesn't have a reference database file system. However we are making one for the upcoming 4.0 release. In theory it's possible in the 3.x versions since we have a file system abstraction layer. For example you can browse a Zip file just like a normal dir.

Best regards,
Spocke - Main developer of TinyMCE

12

Re: Database Operation Upon Clicking on Any MC Filemanager Button

function onFileAction(&$man, $action, $file1, $file2) {
    if ($action == ADD_ACTION) {
        echo "File added: name=" . $file1->getName() . ", path: " . $file1->getAbsolutePath() . ", parent: " . $file1->getParent();
    }

    if ($action == DELETE_ACTION) {
        echo "File added: name=" . $file1->getName() . ", path: " . $file1->getAbsolutePath() . ", parent: " . $file1->getParent();
    }

    if ($action == RENAME_ACTION) {
        echo "File moved: from name=" . $file1->getName() . ", from path: " . $file1->getAbsolutePath() . ", from parent: " . $file1->getParent();
        echo "File moved: to name=" . $file2->getName() . ", to path: " . $file2->getAbsolutePath() . ", to parent: " . $file2->getParent();
    }

    return true;
}


can you provide me the .net implementation of this code? can you show me how can i write a plugin so that i can store the file name folder name in the database?

thanks,
qamar

13

Re: Database Operation Upon Clicking on Any MC Filemanager Button

No that is out side the scope of the support I can give for the products. The .NET API is very similar to the code above so see the code above as pseudo logic for that.

Best regards,
Spocke - Main developer of TinyMCE

14

Re: Database Operation Upon Clicking on Any MC Filemanager Button

at least let me know where should i write the sql query and all while uploading, deleting, editing and renaming the files?

15

Re: Database Operation Upon Clicking on Any MC Filemanager Button

You can write your own .NET plugin then tie in to the onFileAction event by implementing that method. We ship an example plugin with the package that should be enough details if you have basic .NET development skills.

Best regards,
Spocke - Main developer of TinyMCE

16

Re: Database Operation Upon Clicking on Any MC Filemanager Button

i have been asking you the same question in different ways over and over. what is this onfileaction event ? is it a jscript function or a server side .net function? if server side how can i see this function (which file it resides)? hope this time its clear to you.

17

Re: Database Operation Upon Clicking on Any MC Filemanager Button

Ok.

1. Open filemanager\plugins\_Template\src\csharp\TemplatePlugin.cs
2. Locate OnFileAction
3. Notice that this method will be called everytime a file is added/removed/renamed etc.
4. Take the _Template plugin and create your own plugin.
5. Add the SQL stuff to the method described in 2 and 3.
6. Compile it to a DLL the dll can be placed in the bin directory in your plugin for example filemanager\plugins\myplugin\bin.
7. Open the filemanager/web.config
8. Add your new plugin to the plugins config section needs to be the name of the class you created in your plugin.

The above steps needs basic .NET development skills also the API documentation is found in filemanager\docs\FileManager_API.chm the different events are described with comments in the _Template plugin as well as in the API documentation.

Best regards,
Spocke - Main developer of TinyMCE

18

Re: Database Operation Upon Clicking on Any MC Filemanager Button

yeah spocke himself is a great help. he can answer all of us but i believe he does not have enough time. it is absolutely ok annabelle if you cant help me out

19

Re: Database Operation Upon Clicking on Any MC Filemanager Button

Who is annabelle?

Greetings from Germany,

Felix Riesterer.
(-> about me and this forum <-)

20

Re: Database Operation Upon Clicking on Any MC Filemanager Button

Was some spam i deleted, at least I think so.

Afraithe
TinyMCE Developer
Moxiecode Systems

21

Re: Database Operation Upon Clicking on Any MC Filemanager Button

Yeah some of those spammers are really tricky to spot. They start posting like a normal user then after a while they edit their post and add spam junk really annoying. But we have some ideas to prevent that in the future. smile

Best regards,
Spocke - Main developer of TinyMCE

22

Re: Database Operation Upon Clicking on Any MC Filemanager Button

My need:
- I want the images to be stored and retrieved from a Database table rather than the folder.

Achieved so far:
- I have bought a license of Image Manager and File Manager.
- I have created my own plugin and am able to get the following parameters: action, file1 and file2

What are the next set of steps to be followed ? roll
Any guidance will be highly appreciated.

Last edited by Rita (2011-05-03 09:34:59)

23

Re: Database Operation Upon Clicking on Any MC Filemanager Button

It's tricky to have a pure database storage plugin since some operations like image scaling is done on local files in the current version. Also I'm not sure if we will support database blobs even in the 4.0 version since it's a very slow process getting an image out, manipulating it and putting it back in to the database.

Best regards,
Spocke - Main developer of TinyMCE