V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
推荐工具
RoboMongo
推荐书目
50 Tips and Tricks for MongoDB Developers
Related Blogs
Snail in a Turtleneck
krazy
V2EX  ›  MongoDB

关于gridfs一个很诡异的问题..

  •  
  •   krazy · Mar 3, 2012 · 6241 views
    This topic created in 5168 days ago, the information mentioned may be changed or developed.
    <?php
    //连接Mongo并初始化GFS
    $conn = new Mongo();
    $db = $conn->datas;
    $grid = $db->getGridFS();
    $filesCollection = $db->files;

    $size = $_FILES['upload']['size'];
    $md5 = md5_file($_FILES['upload']['tmp_name']);
    $exists = $grid->findOne(array('md5'=>$md5,'length'=>$size),array('md5'));
    if(empty($exists)){
    ....$id = $grid->storeFile($_FILES['upload']['tmp_name']);
    ....echo "uploaded";
    }
    else{
    ....unlink($_FILES['upload']['tmp_name']);
    ....echo "file exists";
    }
    ?>

    就是这么一个很简单的上传。
    本地都没有什么问题...
    但是上传到服务器,有时候会报500错误
    有时候上传新文件,成功了,但是还是会打印else里面的file exists...
    实在是不晓得为什么...
    1 replies    1970-01-01 08:00:00 +08:00
    krazy
        1
    krazy  
    OP
       Mar 8, 2012
    会不会是php的问题
    我用python重新写了一遍,就好了,完全没问题
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   5615 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 36ms · UTC 08:23 · PVG 16:23 · LAX 01:23 · JFK 04:23
    ♥ Do have faith in what you're doing.