7

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

Flex60460
  • 933
  • 2
  • 18
  • 49
  • Try what is suggested [in this similar question][1] [1]: http://stackoverflow.com/questions/8229951/load-file-doesnt-work – Yanki Twizzy Feb 02 '12 at 08: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. – Flex60460 Feb 02 '12 at 08:49
  • Do you get any error message, check if u have permission to upload file from that directory – Naveen Kumar Feb 02 '12 at 09: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. – Flex60460 Feb 02 '12 at 13:53
  • 2
    Are you using a remote mysql server? The file has to be on the server, not the client. – Barmar Jul 26 '12 at 17:02

1 Answers1

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
Kailas
  • 3,173
  • 5
  • 42
  • 52