468,783 Members | 1,645 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,783 developers. It's quick & easy.

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:
Expand|Select|Wrap|Line Numbers
  1. 1.    CREATE TABLE `file` ( 
  2. 2.        `id`        Int Unsigned Not Null Auto_Increment, 
  3. 3.        `name`      VarChar(255) Not Null Default 'Untitled.txt', 
  4. 4.        `mime`      VarChar(50) Not Null Default 'text/plain', 
  5. 5.        `size`      BigInt Unsigned Not Null Default 0, 
  6. 6.        `data`      MediumBlob Not Null, 
  7. 7.        `created`   DateTime Not Null, 
  8. 8.        PRIMARY KEY (`id`) 
  9. 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
Apr 22 '10 #1
1 1647
Atli
5,058 Expert 4TB
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.)
Apr 23 '10 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

8 posts views Thread by Sticks | last post: by
3 posts views Thread by somaBoy MX | last post: by
6 posts views Thread by Eric Robinson | last post: by
1 post views Thread by Brian Sadler | last post: by
5 posts views Thread by news | last post: by
4 posts views Thread by Robert Blackwell | last post: by
6 posts views Thread by ssharpjr | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
2 posts views Thread by Marin | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.