consiglieri has asked for the wisdom of the Perl Monks concerning the following question:

Hi all I would like to create a document database that will hold primarily wordprocessing documents, i.e msword or openoffice documents. I understand how to do this. The catch is this. I would like to, via a webbrowser, be able to open a template document in the mysql database using the wordprocessor on my local machine, write my document, then save it as a new document in the database and at the same time saving the document using an client_id from another database. This way i could later search the database to find all documents connected to a certain client id. Anyway, dont want to ramble..what i could do with is some pointers on what a reasonable approach would be to do this. Especially the part concerning picking up a client id and using it as part of the name of the document. As english is not my native language I can only hope i phrased myself in an understandable manner.

Replies are listed 'Best First'.
Re: Perl Cgi mysql document management
by jbrugger (Parson) on Mar 07, 2005 at 11:48 UTC
    In your case. I'd let a client download the current version, edit it, and upload it (via a web-interface?) to the server. There, the server can handle versioning, saving or overwrite the current and or old document.
Re: Perl Cgi mysql document management
by samizdat (Vicar) on Mar 07, 2005 at 13:28 UTC
    Quite understandable. :D

    Catching an identifier and attaching it to a file name is part of the upload-file syntax. You do have to assume that your user uploads the proper file. Unless you use ActiveX or some such dangerous extension, your user does have to save the edited template and then upload it manually to a File Upload dialog on your web system.

    That said, you can use Perl to grab either a stored cookie value or a login ID from a log in sequence and create a filename from one of those values.
      Yes uploading via browser is doable..however if possible I would like to have the user use the wordprocessing program and when he/she saves the right name is chosen and the document is saved to the database..i'm assuming my users will be lazy and forget to do an upload via the webrowser (then again maybe i'm not doing my users justice :) ). Anyway, perhaps its not possible. The user would fist be accessing a website, then choosing a client_id and then click on a button and voila the wordprocessor starts and the document is allready named klient_id + and incremental number. Then when saving it goes back to the database. Ah well,, i will work on the webuppload to begin with. Thanks for the input guys, always helps to get the mind on the right track because sometimes i find that my train of thought hasnt left the station :)
        Your wish is unfortunately (or fortunately!) not possible, except perhaps within a Java wordprocessor / browser / sandbox environment or something on M$'s Real Soon Now wishlist for .NET. Your WP can't (yet!) save to the 'net, and your 'net system can't steal a file from your filesystem.

        The only other alternative I see is having a daemon or timed ("cron") service on the user's system that automatically checks for edited files and uploads them back to the 'net server.

        Much as we'd all like to see such capabilities, they are too easy to exploit. That's why I used the word "steal" above; I did so deliberately. M$ ActiveX comes to mind, and we all see horror stories of how crackers exploit what's left of it in Outlook and IE.