Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to upload a .doc file into MySQL database using Perl

Status
Not open for further replies.

Yasz

Technical User
Feb 4, 2001
2
SG
Hi,
I need in using perl to upload .doc files to a MySQL database. Currently, upload .gif .jpg .txt .html works fine
but once the file is .doc, it becomes corrupted with all the trailing /0 s and others.

Tried many ways to removes the /0 but the file is still corrupted.

Does anyone have solutions to share? Thanks!
 
Well, I don't know about a solution, but here's why this is happening.

The per DBI version is written on top of c code, and the c mysql interface has the follwoing 2 insert methods:

1. mysql_query(MYSQL *, char *){

}
This is for non-binary queries, and it stops when it hits a \0 or \g, and adds a trailing null.

2. mysql_real_query(MYSQL *, char *, int){

}
This if for binary queries, and does not add a trailing null, or stop at any escape characters.

You need to hunt around in the docs and find out how to call a perl function that will insert a binary file,because that's what a .doc file is, and it obviously has some illegial non-ASCII characters.

You might try the DBI::Mysql mailing list, too, they're pretty helpful, and the guy that wrote the thing monitors it (J. Leffler).

MWB.


Disclaimer:
Beware: Studies have shown that research causes cancer in lab rats.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top