update pro pic error

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    update pro pic error

    hello ppl..

    i am facing problem in uploading pic in pro. i cant figure out the problem.i seen code but i cant find it.

    error is imagejpeg() [function.imagejpeg]: Unable to open './avatars/2u.jpg' for writing: Permission denied in /home/mysite/public_html/mysite/genproc.php on line 2287

    i tried to put chmod to 777 though it dont worked. it says permission denied so i tried to put chmod to 777 so wats wrong in this code?


    PHP Code:
    else if($action=="upavat"){

    addonline(getuid_sid($sid),"Uploading Avatar Image","");
        echo 
    "<head>";
        echo 
    "<title>Uploading Avatar Image</title>";
        echo 
    "<link rel=\"stylesheet\" type=\"text/css\" href=\"../themes/$theme[0]\">";
        echo 
    "</head>";
        echo 
    "<body>";
    $size $_FILES['attach']['size']/1024;

    $origname $_FILES['attach']['name'];

    $res false;

    $ext explode("."strrev($origname));

    switch(
    strtolower($ext[0])){

            case 
    "gpj":

        
    $res true;

        break;

        case 
    "gepj":

        
    $res true;

        break;

    }

    $tm time();

    $uploaddir "./avatars";

    if(
    $size>512){

        echo 
    "File is larger than 512KB";

        

    }

    else if (
    $res!=true){

                                        

        echo 
    "File type not supported! Please attach only a JPG/JPEG.";

    }



    else{

        
    $name getuid_sid($sid);

        
    $uploadfile $name.".".$ext;

        
    $uppath=$uploaddir."/".$uploadfile;

        
    move_uploaded_file($_FILES['attach']['tmp_name'], $uppath);

        
    $filewa=$uppath;

        list(
    $width$height$type$attr) = getimagesize($filewa);

        
    $newname=$uploaddir."/".$name."u.jpg";

        
    $newheight = ($height*128)/$width;

        
    $newimg=imagecreatetruecolor(128$newheight);

        
    $largeimg=imagecreatefromjpeg($filewa);

        
    imagecopyresampled($newimg$largeimg0000128$newheight$width$height);

        
    imagejpeg($newimg$newname);

        
    imagedestroy($newimg);

        
    imagedestroy($largeimg);

        
    $file1=$name."u.jpg";

        
    unlink($filewa);

            
    $res1 mysql_query("UPDATE ibwf_users SET avatar='./avatars/$file1' WHERE id='".$name."'");

    }

    if(
    $res1){

        echo 
    "Your file $origname was successfully uploaded and set to your profile!";

    }

    else {

        echo 
    "File couldn't be processed! Check error messages and report to a moderator or admin if applicable.";

    }



    echo 
    "<br/><br/><b>0 </b><a accesskey=\"0\" href=\"index.php?action=main\"><img src=\"../images/home.gif\" alt=\"\"/>Home</a>";
        echo 
    "</p>";
        echo 
    "</body>";

    sigpic

    WANT GOOD CHEAP HOSTING WITH 99% UPTIME? THEN PM ME FOR DETAILS!!

    #2
    the folder that its getting uploaded to set 777 ???? is it being uploaded to a folder that exists ???
    Wapchat4u


    Topsites4u

    Comment


      #3
      It won't be a chmod problem as GD Library is unable to open - (which it means it only needs readable permission)

      Next - does the file exists on the server?

      if yes then is the folder in the correct directory?

      Next try using:
      ../avatar/

      instead of
      /avatar/

      Still causing problems? you may need to change the current working directory eg:
      PHP Code:
      $old getcwd();
      chdir('avatars');
      //Do your uploading etc here:
      chdir($old); 

      Comment


        #4
        re

        Originally posted by thunderwap View Post
        hello ppl..

        i am facing problem in uploading pic in pro. i cant figure out the problem.i seen code but i cant find it.

        error is imagejpeg() [function.imagejpeg]: Unable to open './avatars/2u.jpg' for writing: Permission denied in /home/mysite/public_html/mysite/genproc.php on line 2287

        i tried to put chmod to 777 though it dont worked. it says permission denied so i tried to put chmod to 777 so wats wrong in this code?


        PHP Code:
        else if($action=="upavat"){

        addonline(getuid_sid($sid),"Uploading Avatar Image","");
            echo 
        "<head>";
            echo 
        "<title>Uploading Avatar Image</title>";
            echo 
        "<link rel=\"stylesheet\" type=\"text/css\" href=\"../themes/$theme[0]\">";
            echo 
        "</head>";
            echo 
        "<body>";
        $size $_FILES['attach']['size']/1024;

        $origname $_FILES['attach']['name'];

        $res false;

        $ext explode("."strrev($origname));

        switch(
        strtolower($ext[0])){

                case 
        "gpj":

            
        $res true;

            break;

            case 
        "gepj":

            
        $res true;

            break;

        }

        $tm time();

        $uploaddir "./avatars";

        if(
        $size>512){

            echo 
        "File is larger than 512KB";

            

        }

        else if (
        $res!=true){

                                            

            echo 
        "File type not supported! Please attach only a JPG/JPEG.";

        }



        else{

            
        $name getuid_sid($sid);

            
        $uploadfile $name.".".$ext;

            
        $uppath=$uploaddir."/".$uploadfile;

            
        move_uploaded_file($_FILES['attach']['tmp_name'], $uppath);

            
        $filewa=$uppath;

            list(
        $width$height$type$attr) = getimagesize($filewa);

            
        $newname=$uploaddir."/".$name."u.jpg";

            
        $newheight = ($height*128)/$width;

            
        $newimg=imagecreatetruecolor(128$newheight);

            
        $largeimg=imagecreatefromjpeg($filewa);

            
        imagecopyresampled($newimg$largeimg0000128$newheight$width$height);

            
        imagejpeg($newimg$newname);

            
        imagedestroy($newimg);

            
        imagedestroy($largeimg);

            
        $file1=$name."u.jpg";

            
        unlink($filewa);

                
        $res1 mysql_query("UPDATE ibwf_users SET avatar='./avatars/$file1' WHERE id='".$name."'");

        }

        if(
        $res1){

            echo 
        "Your file $origname was successfully uploaded and set to your profile!";

        }

        else {

            echo 
        "File couldn't be processed! Check error messages and report to a moderator or admin if applicable.";

        }



        echo 
        "<br/><br/><b>0 </b><a accesskey=\"0\" href=\"index.php?action=main\"><img src=\"../images/home.gif\" alt=\"\"/>Home</a>";
            echo 
        "</p>";
            echo 
        "</body>";

        i can already see your problem change $uploaddir = "avatars";
        if your script is in your root folder of the site u dont need ../ ./ etc this is why u face your problem.
        Last edited by ozziemale31; 14.08.13, 23:32.









        Dont Ask Me Dumb Questions.Or you'l get a Dumb Answer..
        Want A Profesional Logo or Theme For Your wap site Pm Me.If I Have The Time Ill Make It For Free

        Comment


          #5
          another thing could be the 777 chmod... If above suggestion doesn't work, try chmod to 755. I know 777 can give issues on some servers i have used...
          C3 Themes: http://c3themes.wen.ru/index.html
          Find Files: http://mystarter.tk/?goto=X-search

          Comment


            #6
            i am not using site in root directory. i am using in subdomain.


            i tried to change $uploaddir = "./avatars"; into $uploaddir = "../avatars";

            this worked and says profile successfully uploaded and set to the profile but it does not exists in folder when i see. so it does not displays in profile too.
            Last edited by thunderwap; 17.08.13, 06:35.
            sigpic

            WANT GOOD CHEAP HOSTING WITH 99% UPTIME? THEN PM ME FOR DETAILS!!

            Comment


              #7
              Originally posted by thunderwap View Post
              i am not using site in root directory. i am using in subdomain.


              i tried to change $uploaddir = "./avatars"; into $uploaddir = "../avatars";

              this worked and says profile successfully uploaded and set to the profile but it does not exists in folder when i see. so it does not displays in profile too.
              ../ refers to a setup like this the sub folders are sim like so so if your script is in the web folder we use ../avatars
              avatars
              ecards
              smilies
              images
              mms
              share
              web
              wap

              --------------------------------------------------
              Now here is different we dont need to refer to ../ we just use avatars

              avatars
              ecards
              smilies
              images
              mms
              share
              404.htm
              500.htm
              403.htm
              indx.php
              config.php
              avatars.php
              avupload.php

              Code:
              $name = getuid_sid($sid);
              
              $size = $_FILES['attach']['size']/1024;
              
              $origname = $_FILES['attach']['name'];
              
              $res = false;
              
              $ext = explode(".", strrev($origname));
              
              switch(strtolower($ext[0])){
              
                      case "gpj":
              
              	$res = true;
              
              	break;
                   case "gnp":
              
              	$res = true;
              
              	break;
                  case "png":
              
              	$res = true;
              
              	break;
                  case "fig":
              
              	$res = true;
              
              	break;
                  case "gif":
              
              	$res = true;
              
              	break;
              
              	case "gepj":
              
              	$res = true;
              
              	break;
              
              }
              
              $tm = time();
              
              $uploaddir = "avatars";
              
              if($size>512){
                    echo "<div class=\"error\"><img src=\"images/no.jpg\" alt=\"-\"/>";
                              echo "<big><strong>File Is Bigger the 512Kb</strong></big><br/>";
                              echo "</div><br />";
              }
              
              else if ($res!=true){
                     echo "<div class=\"error\"><img src=\"images/no.jpg\" alt=\"-\"/>";
                              echo "<big><strong>File Type Isnt Supported</strong></big><br/>";
                              echo "</div><br />";
              	echo "File type not supported! Please attach only a JPG/JPEG.<br />";
              
              }
              
              
              
              else{
              
              	$name = getuid_sid($sid);
              
              	$uploadfile = $name.".".$ext;
              
              	$uppath=$uploaddir."/".$uploadfile;
              
              	move_uploaded_file($_FILES['attach']['tmp_name'], $uppath);
              
              	$filewa=$uppath;
              
              	list($width, $height, $type, $attr) = getimagesize($filewa);
              
              	$newname=$uploaddir."/".$name."u.jpg";
              
              	$newheight = ($height*128)/$width;
              
              	$newimg=imagecreatetruecolor(128, $newheight);
              
              	$largeimg=imagecreatefromjpeg($filewa);
              
              	imagecopyresampled($newimg, $largeimg, 0, 0, 0, 0, 128, $newheight, $width, $height);
              
              	imagejpeg($newimg, $newname);
              
              	imagedestroy($newimg);
              
              	imagedestroy($largeimg);
              
              	$file1=$name."u.jpg";
              
              	unlink($filewa);
              
                      $res1 = mysql_query("UPDATE ibwf_users SET avatar='avatars/$file1' WHERE id='".$name."'");
                     //$res1 = mysql_query("UPDATE ibwf_users SET avatar='avatars/$file1' WHERE id='".$name."'");// see your error why it doesnt get showen in the dbase?
                    //$res1 = mysql_query("UPDATE ibwf_users SET avatar='$uploaddir/$file1' WHERE id='".$name."'"); // or we can use the default folder name already stated
              }
              
              if($res1){
                         echo "<div class=\"done\"><img src=\"images/ok.gif\" alt=\"-\"/>";
                              echo "<big><strong>$origname Was Successfully Added</strong></big><br/>";
                     echo "</div><br />";
              	echo "Your file $origname was successfully uploaded and set to your profile!";
              
              }
              
              else {
                      echo "<div class=\"error\"><img src=\"images/no.jpg\" alt=\"-\"/>";
                              echo "<big><strong>File Wasnt Processed</strong></big><br/>";
                              echo "</div><br />";
              	echo "File couldn't be processed! Check error messages and report to a moderator or admin if applicable.";
              
              }
              Last edited by ozziemale31; 17.08.13, 10:35.









              Dont Ask Me Dumb Questions.Or you'l get a Dumb Answer..
              Want A Profesional Logo or Theme For Your wap site Pm Me.If I Have The Time Ill Make It For Free

              Comment


                #8
                Originally posted by thunderwap View Post
                i am not using site in root directory. i am using in subdomain.


                i tried to change $uploaddir = "./avatars"; into $uploaddir = "../avatars";

                this worked and says profile successfully uploaded and set to the profile but it does not exists in folder when i see. so it does not displays in profile too.
                $uploaddir = "./avatars";try
                $uploaddir = "../../avatars";
                as subdomain is a directory in main html folder
                an extra ../ allows u to navigate back one more folder









                Dont Ask Me Dumb Questions.Or you'l get a Dumb Answer..
                Want A Profesional Logo or Theme For Your wap site Pm Me.If I Have The Time Ill Make It For Free

                Comment


                  #9
                  Originally posted by ozziemale31 View Post
                  $uploaddir = "./avatars";try
                  $uploaddir = "../../avatars";
                  as subdomain is a directory in main html folder
                  an extra ../ allows u to navigate back one more folder
                  i tried to put $uploaddir = "../../avatars"; and also $res1 = mysql_query("UPDATE ibwf_users SET avatar='../../avatars/$file1' WHERE id='".$name."'");

                  though it dont works. it given me errors in page and it was full with errors.

                  suppose my domain is test.com so my site is subdomain.test.com

                  i put avatars folder in subdomain. and i am not using web folder. index is in subdomain.

                  everything is alrtite but the pic we upload it do not goes into avatars folder. that file name which we upload do not exists in avatars folder and so no profile displays in profile.
                  Last edited by thunderwap; 17.08.13, 15:32.
                  sigpic

                  WANT GOOD CHEAP HOSTING WITH 99% UPTIME? THEN PM ME FOR DETAILS!!

                  Comment


                    #10
                    if the file is not uploading go back to chmod 755 via ftp
                    if the file is still not uploading make sure you have a temp folder for the files to be uploaded to before they are moved to the correct directory.

                    Also would be good to know what those errors say - as we are all just guessing

                    Comment


                      #11
                      Originally posted by something else View Post
                      if the file is not uploading go back to chmod 755 via ftp
                      if the file is still not uploading make sure you have a temp folder for the files to be uploaded to before they are moved to the correct directory.

                      Also would be good to know what those errors say - as we are all just guessing
                      tried to chmod into 755 though not working. i got tmp folder too. and i get errors when i put $uploaddir = "../../avatars";

                      PHP Code:
                      Warningmove_uploaded_file(../../avatars/2.Array) [function.move-uploaded-file]: failed to open streamNo such file or directory in /home/mydomain/public_html/mysubdomain/genproc.php on line 2271

                      Warning
                      move_uploaded_file() [function.move-uploaded-file]: Unable to move '/tmp/phpiGH1RB' to '../../avatars/2.Array' in /home/mydomain/public_html/mysubdomain/genproc.php on line 2271

                      Warning
                      getimagesize(../../avatars/2.Array) [function.getimagesize]: failed to open streamNo such file or directory in /home/mydomain/public_html/mysubdomain/genproc.php on line 2275

                      Warning
                      Division by zero in /home/mydomain/public_html/mysubdomain/genproc.php on line 2279

                      Warning
                      imagecreatetruecolor() [function.imagecreatetruecolor]: Invalid image dimensions in /home/mydomain/public_html/mysubdomain/genproc.php on line 2281

                      Warning
                      imagecreatefromjpeg(../../avatars/2.Array) [function.imagecreatefromjpeg]: failed to open streamNo such file or directory in /home/mydomain/public_html/mysubdomain/genproc.php on line 2283

                      Warning
                      imagecopyresampled(): supplied argument is not a valid Image resource in /home/mydomain/public_html/mysubdomain/genproc.php on line 2285

                      Warning
                      imagejpeg(): supplied argument is not a valid Image resource in /home/mydomain/public_html/mysubdomain/genproc.php on line 2287

                      Warning
                      imagedestroy(): supplied argument is not a valid Image resource in /home/mydomain/public_html/mysubdomain/genproc.php on line 2289

                      Warning
                      imagedestroy(): supplied argument is not a valid Image resource in /home/mydomain/public_html/mysubdomain/genproc.php on line 2291

                      Warning
                      unlink(../../avatars/2.Array) [function.unlink]: No such file or directory in /home/mydomain/public_html/mysubdomain/genproc.php on line 2295
                       Your file scvaga
                      .jpg was successfully uploaded and set to your profile
                      Added after 33 minutes:

                      seems like it works sometimes and sometimes dont. but now it is working now. lets see how far it goes.

                      thanks guys.
                      Last edited by thunderwap; 17.08.13, 19:52.
                      sigpic

                      WANT GOOD CHEAP HOSTING WITH 99% UPTIME? THEN PM ME FOR DETAILS!!

                      Comment


                        #12
                        or we can do this
                        $uploaddir = "../../avatars";
                        changeto
                        $uploaddir = "http://test.com/avatars";

                        in the sql statement use $uploaddir/$file1/
                        the only other solution is prob moving the uploading script into the subdomain and link to it from there









                        Dont Ask Me Dumb Questions.Or you'l get a Dumb Answer..
                        Want A Profesional Logo or Theme For Your wap site Pm Me.If I Have The Time Ill Make It For Free

                        Comment


                          #13
                          you need to set the correct array key on the variable $ext

                          eg:
                          PHP Code:
                          $uploadfile $name.".".$ext[(count($ext)-1)]; 

                          Comment

                          Working...
                          X