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.

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

报告相同问题?

悬赏问题

  • ¥20 matlab计算中误差
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料
  • ¥15 使用R语言marginaleffects包进行边际效应图绘制
  • ¥20 usb设备兼容性问题
  • ¥15 错误(10048): “调用exui内部功能”库命令的参数“参数4”不能接受空数据。怎么解决啊