0

XAMPP for Linux 5.6.20 is not showing uploaded files using php in lubuntu 16.04lts

`

include 'header.php';
 $profile_id=$user['username'];
$imgSrc="";
$result_path="";
$msg="";

if(!isset($_POST['x']) && !isset($_FILES['image']['name'])){
  $temppath='profile_pics/'.$profile_id.'_temp.jpeg';
  if(file_exists($temppath)){@unlink($temppath);}
 }
if(isset($_FILES['image']['name'])){


$ImageName=$_FILES['image']['name'];


$ImageSize=$_FILES['image']['size'];

$ImageTempName=$_FILES['image']['tmp_name'];


$ImageType=@explode('/',$_FILES['image']['type']);

$type=$ImageType[1];

$uploaddir=$_SERVER['DOCUMENT_ROOT']."/profile_pics";
$file_temp_name=$profile_id.'_original.'.md5(time()).'n'.$type;
$fullpath=$uploaddir."/".$file_temp_name;

$file_name=$profile_id.'_temp.jpeg';
$fullpath_2=$uploaddir."/".$file_name;


$move=move_uploaded_file($ImageTempName,$fullpath);


 chmod($fullpath,0777);


 if(!$move){


 die('file not uploaded');
   }
else{
  $imgSrc="profile_pics/".$file_name;
   $msg="upload complete";
    $src=$file_name;



  }
  clearstatcache();
  $original_size=getimagesize($fullpath);
  $original_width=$original_size[0];
  $original_height=$original_size[1];
  $main_width=500;
  $main_height=$original_height/($original_width/main_width);
  if($_FILES["image"]["type"]=="image/gif"){
    $src2=imagecreatefromgif($fullpath);
  }
  elseif($_FILES["image"]["type"]=="image/jpeg" || $_FILES["image"] 
  ["type"]=="image/pjpeg"){
    $src2=imagecreatefromjpeg($fullpath);
  }
  elseif($_FILES["image"]["type"]=="image/png"){
    $src2=imagecreatefrompng($fullpath);
  }else{
    $msg.="There was an error uploading the file please upload a .jpg, 
.gif or .png file <br/>";
}
$main=imagecreatetruecolor($main_width,$main_height);

imagecopyresampled($main,$src2,0,0,0,0,$main_width,$main_height,$original_ width,$original_height); $main_temp=$fullpath_2; imagejpeg($main,$main_temp,90); chmod($main_temp,0777); imagedestroy($src2); imagedestroy($main); @ unlink($fullpath);

} if(isset($_POST['x'])){ $type=$_POST['type']; $src='profile_pics/'.$_POST['src']; $finalname=$profile_id.md5(time()); if($type=='jpg'||$type=='jpeg'||$type=='JPG'||$type=='JPEG'){ $targ_w=$targ_h=1500; $jpeg_quality=90; $img_r=imagecreatefromjpeg($src); $dst_r=imagecreatetruecolor($targ_w,$targ_h); imagecopyresampled($dst_r,$img_r,0,0,$_POST['x'],$_POST['y'],$targ_w,$targ_h,$_POST['w'],$_POST['h']); imagejpeg($dst_r,"profile_pics/".$finalname."n.jpeg",90);

}else if($type=='png'||$type=='PNG'){
    $targ_w=$targ_h=150;
    $jpeg_quality=90;
    $img_r=imagecreatefrompng($src);
    $dst_r=imagecreatetruecolor($targ_w,$targ_h);
    imagecopyresampled($dst_r,$img_r,0,0,$_POST['x'],$_POST['y'],$targ_w,$targ_h,$_POST['w'],$_POST['h']);
    imagejpeg($dst_r,"profile_pics/".$finalname."n.jpeg",90);
    }else if($type=='gif'||$type=='GIF'){
    $targ_w=$targ_h=150;
    $jpeg_quality=90;
    $img_r=imagecreatefromgif($src);
    $dst_r=imagecreatetruecolor($targ_w,$targ_h);
    imagecopyresampled($dst_r,$img_r,0,0,$_POST['x'],$_POST['y'],$targ_w,$targ_h,$_POST['w'],$_POST['h']);
    imagejpeg($dst_r,"profile_pics/".$finalname."n.jpeg",90);
}

imagedestroy($img_r);
imagedestroy($dst_r);
@ unlink($src);
$result_path="profile_pics/".$finalname."n.jpeg";
$insert_pic_query=mysqli_query($db,"UPDATE profile SET image='$result_path' WHERE username='$userLoggedIn'");
header("Location:" .$userLoggedIn);

} ?>

Upload something :





$('#Overlay').show(); $('#formExample').hide(); " border="0" id="jcrop_target" style="border:0px #990000 solid; position:relative; margin:0px 0px 0px 0px; padding=0px;"/>

Crop Profile Image



Crop / Resize your uploaded profile image
Once you are happy with your profile image then please click save.


" name="src"/> " style="position:relative; margin:10px auto; width:150px; height:150px;"/>

?>

`

  • FYI: Lubuntu 16.04 LTS being a flavor of Ubuntu had only 3 years of supported life (lubuntu.me/xenial-5-released fridge.ubuntu.com/2019/03/01/ubuntu-16-04-6-lts-released) which ended 2019-April. Ubuntu 16.04 LTS Server (no desktop) or Desktop (Unity 7) have 5 years of supported life and are still supported. Refer release notes, or use ubuntu-support-status or your own system to confirm this is the case. I suggest you move to a supported release of Lubuntu for security reasons, unless you're off-line or are aware of risks. – guiverc Mar 26 at 5:43
  • @guiverc do u have any idea about above problem – Srikar Nagam Mar 26 at 10:09
  • I didn't really look; you are using an EOL release, and whilst Ubuntu and flavors are happy for users to continue using a release after it's EOL, we don't want to encourage its use by providing support for it (support ended for 16.04 flavors [except Kylin] in April 2019). We also know most users who know how to back-port their own fixes to their now unsupported packages in order to keep themselves safe & patched, won't need support anyway usually. – guiverc Mar 26 at 10:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.