I got a table with columns but i'm trying to update the 'img' column to a specific image.
我有一个带有列的表,但我正在尝试将'img'列更新为特定图像。
This is what I tried :
这是我试过的:
UPDATE employees
SET img="(LOAD_FILE('C:/Users/Test/Desktop/Test.png')"
WHERE wname='Foo';
Sadly enough the picture doesn't get converted to a real image.
可悲的是,图片无法转换为真实图像。
2 个解决方案
#1
You are using LOAD_FILE in wrong manner, Try this :
你正在以错误的方式使用LOAD_FILE,试试这个:
UPDATE employees
SET img=LOAD_FILE('C:/Users/Test/Desktop/Test.png')
WHERE wname='Foo';
See detail : http://dev.mysql.com/doc/refman/5.1/en/string-functions.html#function_load-file
详见:http://dev.mysql.com/doc/refman/5.1/en/string-functions.html#function_load-file
#2
In you query you are just setting the value of img as "(LOAD_FILE('C:/Users/Test/Desktop/Test.png')" because of the double coats. So instead of file being uploaded path location is being inserted "(LOAD_FILE('C:/Users/Test/Desktop/Test.png')"
在您的查询中,您只是将img的值设置为“(LOAD_FILE('C:/Users/Test/Desktop/Test.png')”,因为双层大衣。因此,不是上传文件路径位置正在插入“ (LOAD_FILE( 'C:/Users/Test/Desktop/Test.png')”
@Sagar Joon is absolutely right you have do the way he is saying.
@Sagar Joon绝对是对的,你按照他说的方式行事。
#1
You are using LOAD_FILE in wrong manner, Try this :
你正在以错误的方式使用LOAD_FILE,试试这个:
UPDATE employees
SET img=LOAD_FILE('C:/Users/Test/Desktop/Test.png')
WHERE wname='Foo';
See detail : http://dev.mysql.com/doc/refman/5.1/en/string-functions.html#function_load-file
详见:http://dev.mysql.com/doc/refman/5.1/en/string-functions.html#function_load-file
#2
In you query you are just setting the value of img as "(LOAD_FILE('C:/Users/Test/Desktop/Test.png')" because of the double coats. So instead of file being uploaded path location is being inserted "(LOAD_FILE('C:/Users/Test/Desktop/Test.png')"
在您的查询中,您只是将img的值设置为“(LOAD_FILE('C:/Users/Test/Desktop/Test.png')”,因为双层大衣。因此,不是上传文件路径位置正在插入“ (LOAD_FILE( 'C:/Users/Test/Desktop/Test.png')”
@Sagar Joon is absolutely right you have do the way he is saying.
@Sagar Joon绝对是对的,你按照他说的方式行事。