开发者

Default mySQl Blob Column or upload an image from server directory

开发者 https://www.devze.com 2023-03-30 14:56 出处:网络
I have this simple problem but I had a hard time of finding a solution. I want my web application to have a default user image upon his registration. My application uploads directly the images to the

I have this simple problem but I had a hard time of finding a solution. I want my web application to have a default user image upon his registration. My application uploads directly the images to the database in a blob type column and I don't want to use directory uploading. Are there any ways that I can set a default value for blob? or any code that upload an image that came from a server directory to mysql datab开发者_开发百科ase? Thanks


From the Documentation:

BLOB and TEXT columns cannot have DEFAULT values.

Proposed solution:

Why don't you save the file somewhere on your server where it can be served as a static file, and hyperlink that static file instead if your blob column is null?

0

精彩评论

暂无评论...
验证码 换一张
取 消