9

I try to insert a Open Office document on a blob field. To do this I try

INSERT INTO my_table (stamp, docFile) VALUES (NOW(), LOAD_FILE('/tmp/my_file.odt'));

This works well on windows but on Mac Os the file isn't load on docFile field.

Is anyone has experience about that?

Thanks

5
  • Try what is suggested [in this similar question][1] [1]: stackoverflow.com/questions/8229951/load-file-doesnt-work Commented Feb 2, 2012 at 8:33
  • As I've done all you suggest, it's why I post. Thanks. If I use tools like phpmyAdmin or Navicate to do the same task, all work well. Commented Feb 2, 2012 at 8:49
  • Do you get any error message, check if u have permission to upload file from that directory Commented Feb 2, 2012 at 9:55
  • I check permission, and all it's good. I use zend and I did 2 tests. The first I place folder and file on webroot, no result, second I place folder and while on mysql root : same result, none. And if I do the same with phpMyAdmin the file is loaded on mysql. Commented Feb 2, 2012 at 13:53
  • 2
    Are you using a remote mysql server? The file has to be on the server, not the client. Commented Jul 26, 2012 at 17:02

1 Answer 1

1

File.separator is either / or \ that is used to split up the path to a specific file. For example on Windows it is \ or C:\Documents\Test. But on Mac it is /.

So use File.separator instead of / or \, then it will work for both Mac and Windows.

You can Update the column value having type 'blob'

UPDATE `TableName` SET `ColumnName`=LOAD_FILE('FilePath/FileName.bin') WHERE `YourCondition` 
// FilePath -> C:/foldername/filename.bin
Sign up to request clarification or add additional context in comments.

1 Comment

It doesn't work: 0 row(s) affected Rows matched: 1 Changed: 0 Warnings: 0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.