duanhua9398 2016-06-08 20:36
浏览 30
已采纳

如何使用PHP将图像插入数据库[关闭]

I'm wanting to allow a person to upload an image to the website that I'm making and I don't know how to do it. I know how to make the HTML form but after that, I don't have a clue. I have made the database and I'm wanting to do it in PHP.

  • 写回答

1条回答 默认 最新

  • dongyang5716 2016-06-08 20:41
    关注

    Generally the best way to do this, is to upload the file to your server, and then store the path to it in the database.

    File Upload: http://php.net/manual/en/features.file-upload.php

    You need to choose a database, MySQL is a common and free option:

    https://www.mysql.com/

    As mentioned in comment below, (I haven't used it before but had a read and looks like a better option) https://mariadb.com/

    PDO (recommended library to use with several types of databases): http://php.net/manual/en/book.pdo.php

    Note that there are many security considerations when letting people upload files to your server: https://security.stackexchange.com/questions/32852/risks-of-a-php-image-upload-form/32853#32853

    All in all, it may be longer than you think before your friend is uploading that file - but it will be worth it

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 解决一个加好友限制问题 或者有好的方案
  • ¥15 关于#java#的问题,请各位专家解答!
  • ¥15 急matlab编程仿真二阶震荡系统
  • ¥20 TEC-9的数据通路实验
  • ¥15 ue5 .3之前好好的现在只要是激活关卡就会崩溃
  • ¥50 MATLAB实现圆柱体容器内球形颗粒堆积
  • ¥15 python如何将动态的多个子列表,拼接后进行集合的交集
  • ¥20 vitis-ai量化基于pytorch框架下的yolov5模型
  • ¥15 如何实现H5在QQ平台上的二次分享卡片效果?
  • ¥30 求解达问题(有红包)