写这种东西关键是找出原因,有时候没有出错信息,你也要让它出错,就是调式功能,比如写句:echo "3252323";看看到底执行到哪步才不行的,这样才能对自己有所提高

解决方案 »

  1.   

    这个问题在本版问过
    我的方法是:
    先用copy函数把上传的文件复制到你有权限操作的目录下面
    ,然后fopen函数打开文件,用fread函数读取图片,得到$string,用base64_encode()函数加密$string然后把这个$string 和你的文字一起插入到数据库,显示的时候用base64_decode()解密显示图片
      

  2.   

    _Shakespeare(网络骑士) 大哥:需要这么复杂么?我想很多地方都会用到这种技术啊,唉你能不能把那个版的网址粘上来啊,我是个初学者,你说的我不太理解,谢谢!!1
      

  3.   

    你试着把PHP.INI文件里的max_execution_time一项数值改大一点,
    或者自己在程序里加个函数set_time_limit(120)
      

  4.   


    <?
    @$link=mysql_pconnect("localhost","root","rpass007") or
    die ("登陆服务器失败,请稍候再试");
    mysql_select_db($db);
    $date=date('Y-m-d H:i:s');
    if((($db=="foltyx"&&$tb=="wlg_master")||($db=="foljrbd"&&$tb=="tpxw"))||($db=="foljrxt"&&($tb=="shpx"||$tb=="tswl")))//for tyx jrbd jrxt
    {
            if(chop($imagein)!="none")
                  {
                  $picuppath="/home/fol/php/admin/";         //define up pic path
                  $dirname="picup";
                  if(!(chdir($picuppath)))
                     {
                        die("can not change path!");
                     }
                  if(!(file_exists("$dirname")))
                     {
                        if(!(mkdir($dirname,0777))) die("can not make dir!");
                        if(!(chmod($dirname,0777))) die("can not change dir mode!");
                     }
                  if(!(chdir($dirname))) die("can not change dir!");
                  $dirpath=$dirname."/";
                  $imagepath=$picuppath.$dirpath;                      //path end        $image="";
            $imagename="";
            $imagetype="";
            $nowtime=time();                  $imagename=$imagein_name ;                         //old pic name for db
                      $imagetail=strrchr($imagename,".");                //get pic name type name
                      $imagename=$nowtime.$imagetail;
                      if(!copy($imagein,$imagepath.$imagename)) die("up pic false"); //up pic end
                      $size=getimagesize($imagename);                        //get size array,for now in uppic,so just imagename else dirpaht
                      $imgwidth=$size[0];
                      $imgheight=$size[1];
                      $imgsize=$size[3];
                      unlink($imagename);                                     //delete pic in remote                $image=base64_encode(fread(fopen($imagein,"r"),10000000));     //inset db begin
                    $imagetype=$imagein_type ;
                    $imgtype=$imagetype;
                    unlink($imagein);               $imgoldname=$imagename;
                   $imgname=$imagename;
                   $imgbody=$image;
    if($db=="foljrbd"&&tb=="tpxw"){//there is no summary in tpxw of foljrbd,so ...
    $result =mysql_query("insert into $tb (title,content,date,author,origin,imgoldname,imgtype,imgname,imgwidth,imgheight,imgsize,imgbody) values('$title','$content','$date','$author','$origin','$imgoldname','$imgtype','$imgname','$imgwidth','$imgheight','$imgsize','$imgbody')",$link);
    }
    else{//tpxw of foljrbd
    $result =mysql_query("insert into $tb (title,summary,content,date,author,origin,imgoldname,imgtype,imgname,imgwidth,imgheight,imgsize,imgbody) values('$title','$summary','$content','$date','$author','$origin','$imgoldname','$imgtype','$imgname','$imgwidth','$imgheight','$imgsize','$imgbody')",$link);
    }
                   }
                   else die("请上传图片");
    }//end of pic or pic with no summary
    elseif($db=="foljrbd"&&$tb=="cjzt"){//beggin of cjzt of fol jrbd
    $result =mysql_query("insert into $tb (title,content,date,author,origin,topic) values('$title','$content','$date','$author','$origin','$topic')",$link);
    }//end of cjzt of fol jrbd
    elseif($db=="foljrsx"&&$tb=="pshzl")//for jrsx
    {
            if(chop($imagein)!="none")
                  {
                  $picuppath="/home/fol/php/jrsx/";         //define up pic path
                  $dirname="article";
                  if(!(chdir($picuppath)))
                     {
                        die("can not change path!");
                     }
                  if(!(file_exists("$dirname")))
                     {
                        if(!(mkdir($dirname,0777))) die("can not make dir!");
                        if(!(chmod($dirname,0777))) die("can not change dir mode!");
                     }
                  if(!(chdir($dirname))) die("can not change dir!");
                  $dirpath=$dirname."/";
                  $imagepath=$picuppath.$dirpath;                      //path end        $image="";
            $imagename="";
            $imagetype="";
            $nowtime=time();                  $imagename=$imagein_name ;                         //old pic name for db
                      $imagetail=strrchr($imagename,".");                //get pic name type name
                      $imagename=$nowtime.$imagetail;
                      if(!copy($imagein,$imagepath.$imagename)) die("up pic false"); //up pic end
                      //unlink($imagename);                                     //delete pic in remote                //$image=base64_encode(fread(fopen($imagein,"r"),10000000));     //inset db begin
                    $imagetype=$imagein_type ;
                    $imgtype=$imagetype;
                    unlink($imagein);               $imgoldname=$imagename;
                   $imgname=$imagename;
                   $imgbody=$image;
    $result =mysql_query("insert into $tb (title,content,date,author,origin,artcloldname,artcltype,artclname) values('$title','$content','$date','$author','$origin','$imgoldname','$imgtype','$imgname')",$link);
                   }
                   else die("请上传论文");
    }//end of art
    elseif($db=="foljrxt"&&($tb=="ztjz"||$tb=="alfx")){
    $result =mysql_query("insert into $tb (title,summary,content,date,author,origin) values('$title','$summary','$content','$date','$author','$origin')",$link);
    }
    else{
    $result =mysql_query("insert into $tb (title,content,date,author,origin) values('$title','$content','$date','$author','$origin')",$link);
    }
    if (mysql_affected_rows()==1)
    {
            ?>
            添加成功,请返回!
            <p><a href="add.php?db=<? echo $db ?>&tb=<? echo $tb ?>">返回</a> </p>
            <?
    }
    else
    {
            ?>
            添加不成功,请稍候再试!
            <p><a href="add.php?db=<? echo $db ?>&tb=<? echo $tb ?>">返回</a> </p>
            <?
    }
    ?>
    具体的地方需要你自己改一下浅妄薄见,望与斟酌