Please Help ! Not Transfering To /photo/ Php Code

Discussion in 'PHP' started by locals, Jun 11, 2008.

  1. #1
    Can someone PLEASE tell my why this code is not working ? ? ?

    function photo_upload(){
    $m_id=cookie_get("mem_id");
    $m_pass=cookie_get("mem_pass");
    $m_phot=cookie_get("mem_phot");
    login_test($m_id,$m_pass);
    global $_FILES,$base_path,$main_url;

    $tmpfname=$_FILES['photo']['tmp_name'];
    $ftype=$_FILES['photo']['type'];
    $fsize=$_FILES['photo']['size'];
    $capture=form_get('capture');
    $main=form_get('main');
    if($main==''){
    $main=0;
    }

    //checkin image size
    if($fsize>500*1024){
    error_screen(10);
    }

    //checkin image type
    if(($ftype=='image/jpeg')||($ftype=='image/pjpeg')){
    $p_type=".jpg";
    }
    elseif($ftype=='image/gif'){
    $p_type=".gif";
    }
    else {
    error_screen(9);
    }
    $row_chk=photo_album_count($m_id,"1","edi");
    if($row_chk<$m_phot) {
    $rand=rand(0,10000);
    $newname=md5($m_id.time().$rand);
    $newname_th=$newname."th";
    $newname_b_th=$newname."bth";
    $old=$base_path."/photos/".$newname.$p_type;
    $thumb1=$base_path."/photos/".$newname_th.".jpg";
    $thumb2=$base_path."/photos/".$newname_b_th.".jpg";

    move_uploaded_file($tmpfname,$base_path."/photos/".$newname.$p_type);

    //creating thumbnails
    if($p_type==".jpg"){
    $srcImage = ImageCreateFromJPEG( $old );
    }//elseif
    elseif($p_type==".gif"){
    $srcImage = ImageCreateFromGIF( $old );
    }//elseif

    $sizee=getimagesize($old);
    $srcwidth=$sizee[0];
    $srcheight=$sizee[1];


    //landscape
    if($srcwidth>$srcheight){
    $destwidth1=65;
    $rat=$destwidth1/$srcwidth;
    $destheight1=(int)($srcheight*$rat);
    $destwidth2=150;
    $rat2=$destwidth2/$srcwidth;
    $destheight2=(int)($srcheight*$rat2);
    }
    //portrait
    elseif($srcwidth<$srcheight){
    $destheight1=65;
    $rat=$destheight1/$srcheight;
    $destwidth1=(int)($srcwidth*$rat);
    $destheight2=150;
    $rat=$destheight2/$srcheight;
    $destwidth2=(int)($srcwidth*$rat);
    }
    //quadro
    elseif($srcwidth==$srcheight){
    $destwidth1=65;
    $destheight1=65;
    $destwidth2=150;
    $destheight2=150;
    }

    $destImage1 = ImageCreateTrueColor( $destwidth1, $destheight1);
    $destImage2 = ImageCreateTrueColor( $destwidth2, $destheight2);
    ImageCopyResized( $destImage1, $srcImage, 0, 0, 0, 0, $destwidth1, $destheight1, $srcwidth, $srcheight );
    ImageCopyResized( $destImage2, $srcImage, 0, 0, 0, 0, $destwidth2, $destheight2, $srcwidth, $srcheight );
    ImageJpeg($destImage1, $thumb1, 80);
    ImageJpeg($destImage2, $thumb2, 80);
    ImageDestroy($srcImage);
    ImageDestroy($destImage1);
    ImageDestroy($destImage2);

    //updating db
    $now=time();
    $photo="photos/".$newname.$p_type;
    $photo_b_thumb="photos/".$newname_b_th.".jpg";
    $photo_thumb="photos/".$newname_th.".jpg";
    if(empty($capture)) $capture=" ";
    $sql_query="update photo set photo=concat(photo,'|$photo'),photo_b_thumb=concat(photo_b_thumb,'|$photo_b_thumb'),
    photo_thumb=concat(photo_thumb,'|$photo_thumb'),capture=concat(capture,'|$capture') where mem_id='$m_id'";
    sql_execute($sql_query,'');

    if($main=='1'){
    $sql_query="update members set photo='$photo',photo_thumb='$photo_thumb',photo_b_thumb='$photo_b_thumb'
    where mem_id='$m_id'";
    sql_execute($sql_query,'');
    }
    } else $err_mess="You can upload only upto $m_phot photo(s).<br>Your maximum limit reached.";

    //redirect
    $location=$main_url."/index.php?mode=user&act=profile&pro=edit&type=photos&err_mess=$err_mess";
    show_screen($location);
    }//function





    PLEASE HELP !



    HERE ARE THE ERRORS I GET
    =========================================================

    Warning: move_uploaded_file(/night_club_vips/photos/dee4d9312453f0de45092c7a94de7b5a.jpeg): failed to open stream: No such file or directory in /night_club_vips/user.php on line 908

    Warning: move_uploaded_file(): Unable to move '/tmp/phpET1r8m' to '/night_club_vips/photos/dee4d9312453f0de45092c7a94de7b5a.jpeg' in /night_club_vips/user.php on line 908

    Warning: imagecreatefromjpeg(/html/flmsh/night_club_vips/photos/dee4d9312453f0de45092c7a94de7b5a.jpeg): failed to open stream: No such file or directory in /night_club_vips/user.php on line 912

    Warning: getimagesize(/html/flmsh/night_club_vips/photos/dee4d9312453f0de45092c7a94de7b5a.jpeg): failed to open stream: No such file or directory in /night_club_vips/user.php on line 918

    Warning: imagecopyresized(): supplied argument is not a valid Image resource in /night_club_vips/user.php on line 951

    Warning: imagecopyresized(): supplied argument is not a valid Image resource in /night_club_vips/user.php on line 952

    Warning: imagejpeg(): Unable to open '/night_club_vips/photos/dee4d9312453f0de45092c7a94de7b5ath.jpeg' for writing in /night_club_vips/user.php on line 953

    Warning: imagejpeg(): Unable to open '/night_club_vips/photos/dee4d9312453f0de45092c7a94de7b5abth.jpeg' for writing in /night_club_vips/user.php on line 954

    Warning: imagedestroy(): supplied argument is not a valid Image resource in /night_club_vips/user.php on line 955

    Warning: Cannot modify header information - headers already sent by (output started at /night_club_vips/user.php:908) in /night_club_vips/functions.php on line 460
     
    locals, Jun 11, 2008 IP
  2. mehmetm

    mehmetm Well-Known Member

    Messages:
    134
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    110
    #2
    hi

    all the other errors are related to first error because the uploaded image couldn't be moved.

    I see, your script (user.php) in night_club_vips directory. Photos folder is also in here.
    So don't use
    $base_path
    Code (markup):
    here. Like
    
    move_uploaded_file($tmpfname,"./photos/".$newname.$p_type);
    
    PHP:
    and after doing this, check the file/folder permissions for Photos folder.
    (it should be written CHMOD 0777)

    Regards.
     
    mehmetm, Jun 12, 2008 IP
  3. kmap

    kmap Well-Known Member

    Messages:
    2,215
    Likes Received:
    29
    Best Answers:
    2
    Trophy Points:
    135
    #3
    yes its path problem

    Pass the absolute path of the folder on hosting

    Regards

    Alex
     
    kmap, Jun 12, 2008 IP
  4. locals

    locals Well-Known Member

    Messages:
    1,677
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    153
    #4
    Wow You Are The Man I Am Going To Try It Right Now ! ! ! !
     
    locals, Jun 12, 2008 IP
  5. locals

    locals Well-Known Member

    Messages:
    1,677
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    153
    #5
    i will give you the script if it works ! ! ! ! :D:D:D
     
    locals, Jun 12, 2008 IP
  6. php-lover

    php-lover Active Member

    Messages:
    261
    Likes Received:
    21
    Best Answers:
    0
    Trophy Points:
    58
    #6
    base_path variable is declared global inside in your function photo_upload() but its located ouside your function photo_upload() You need to make sure that this path(all the folder is exists) otherewise it produce that error.

    $base_path."/photos/

    Can you post the $base_path variable value.
     
    php-lover, Jun 12, 2008 IP