needing a script to dump pdf files into a MySQL database

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • dparent
    New Member
    • Apr 2010
    • 1

    needing a script to dump pdf files into a MySQL database

    I have a MySQL database and would like to upload multiple pdf files at once and store the information into the db. Here is the db I created:
    Code:
    1.	CREATE TABLE `file` ( 
    2.	    `id`        Int Unsigned Not Null Auto_Increment, 
    3.	    `name`      VarChar(255) Not Null Default 'Untitled.txt', 
    4.	    `mime`      VarChar(50) Not Null Default 'text/plain', 
    5.	    `size`      BigInt Unsigned Not Null Default 0, 
    6.	    `data`      MediumBlob Not Null, 
    7.	    `created`   DateTime Not Null, 
    8.	    PRIMARY KEY (`id`) 
    9.	)
    Is there a script that I can run that will accomplish this? I have created a webpage but can only upload one at a time and would just like to do a full dump of 3000 files at once creating a record for each in the db.
    Thanks
    Last edited by Atli; Apr 23 '10, 09:21 AM. Reason: Added [code] tags.
  • Atli
    Recognized Expert Expert
    • Nov 2006
    • 5062

    #2
    Hey.

    A browser can not do this for you. It only allows single point-and-click uploads. (Meaning: the user has to select each file manually.) This is for obvious security reasons.

    I see three ways to accomplish what you are trying to do:
    1. Upload all the files manually to the server, using FTP or something like that. Then create a server-side script that scans the upload directory and inserts each file it finds.
    2. Create a client-side application (Java, C#, C++, whatever) that acts as a browser, sending each file to the web-application via a HTTP request. - This is of course a lot of work if you only intend to use it once, but it may be a good idea if you intend to do this a lot.
    3. Set the "client" computer (read: your computer) up as a FTP or SSH server, and create a server side script that connects to your computer, downloads the files, and inserts them into the database.


    Any way you choose, you will have to custom make the script to fit your specific situation. There is not ready-made script that you can use. (None that I know of, at least. Perhaps on Google, who knows.)

    Comment

    Working...