还有怎么把图像转为二进制数据,储存在MYSQL数据库上了?

解决方案 »

  1.   

    rename(oldname,newname);把字段的数据类型设为
    mediumtext
      

  2.   

    你上传的时候COPY过来的时候重命名,字节fopen打开!就可以二进制读取了!
      

  3.   

    <?php
    // 在 4.1.0 以前的 PHP 中,需要用 $HTTP_POST_FILES 代替 $_FILES。
    // 在 4.0.3 以前的 PHP 中,需要用 copy() 和 is_uploaded_file() 来代替 move_uploaded_file()。$uploaddir = '/var/www/uploads/';
    $uploadfile = $uploaddir. $_FILES['userfile']['name'];
    print "<pre>";
    if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploaddir . $_FILES['userfile']['name'])) {
        print "File is valid, and was successfully uploaded.  Here's some more debugging info:\n";
        print_r($_FILES);
    } else {
        print "Possible file upload attack!  Here's some debugging info:\n";
        print_r($_FILES);
    }
    print "</pre>";
    ?>bool move_uploaded_file ( string filename, string destination)本函数检查并确保由 filename 指定的文件是合法的上传文件(即通过 PHP 的 HTTP POST 上传机制所上传的)。如果文件合法,则将其移动为由 destination 指定的文件。
      

  4.   

    string destination 就是目标文件的完整路径和文件名例如 "../tmp/20040512.jpg"
    20040512 可以自己生成! 例如 "..tmp/".time().".jpg"
      

  5.   

    <?
    $handle = fopen("image.jpg", "rb");
    $contents = fread ($handle, filesize ($filename));
    fclose ($handle);
    ?>
     $contents就是图片的二进制字符串 ,直接写在数据库就可以了!
      

  6.   

    cokeyang(西北狼) 现在我把二进制字符串直接写在数据库,可是读出来是乱码啊?要怎么读出来了?
      

  7.   

    读出来的时候要
    header 出文件的类型!
      

  8.   

    header("Content-type: image/jpg");这样吗?
      

  9.   

    你有没有下载过PHP编程例啊你去找找,里面有你要的