dqwh26750 2013-04-02 20:22
浏览 59
已采纳

PDO MySQL INSERT在将数据插入数据库之前删除文件扩展名

OK. I haven't used stack exchange in a while, so bear with me. I've researched this exhaustively and can't find an answer.

I'm new to PDO statements in general, and am using it for a site I'm working on, which is going to contain an image uploader. Right now, I have this function:

function addImage($listing_id, $location) {
    $sql = $this->connection->prepare("INSERT INTO images (listing_id, location) VALUES (?, ?)");
      $sql->execute(array($listing_id, $location));
   }

Now, $location comes into this function correct - it is an image location, such as C:\image.png or http://test.com/image.jpg. It is correct at that point. However, upon insertion, the image extensions are being scrubbed, entering only "C:\image" or "http://test.com/image" into the database, which of course is an issue later when I need to use that information to fetch and or modify the image. I assume it's something to do with a sql injection prevention within PDO? I really don't know. Please help!

  • 写回答

1条回答 默认 最新

  • doulanli6146 2013-04-02 22:18
    关注

    The size of the Database field must be large enough to accommodate the inputted data. I.E. Varchar(30) must be large enough to hold the path to your pictures. Try Varchar without a limit.

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

报告相同问题?

悬赏问题

  • ¥15 目详情-五一模拟赛详情页
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?
  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line