1

I am making a profile image system for my website the code I made is working good on my localhost but when I uploaded the website online, I can't upload the images anymore it gives me [500 Internal Server Error] Below is the code I am using to upload the image.

<?php 
session_start();
include '../app_root.php';
// include the database file
require APP_ROOT."/functions/dbh.php";
require  APP_ROOT . '/vendor/autoload.php';
// import the Intervention Image Manager Class
use Intervention\Image\ImageManagerStatic as Image;
$userId = $_SESSION['id'];
$errors = array();
$success = array();
if (isset($_FILES['profileImg']) && !empty($_FILES['profileImg']['name'])) {
    $img = $_FILES['profileImg'];
    $getExt = array("jpg","png","jpeg","gif","jpeg 2000","webp");
  $imageName = strtolower($_FILES['profileImg']['name']);
    $imageNameTmp = strtolower($_FILES['profileImg']['tmp_name']);
    $dividImg = explode('.', $imageName);
    $getImgExt = end($dividImg);
    // check if the file uploaded is an image
    if (!in_array($getImgExt, $getExt)) {
        $errors[] = "Only Those Image Ext Allowed : " . implode(', ', $getExt);
    }else{
                 $fileName = $_FILES['profileImg']['name'];
            $fileTmp  = $_FILES['profileImg']['tmp_name'];
            $fileSize = $_FILES['profileImg']['size'];
            $imgError = $_FILES['profileImg']['error'];
            $fileType = $_FILES['profileImg']['type'];
            if ($imgError !== 0) {
                $errors[] = "Oops! Sorry There was an error uploading your image please try again later";
            }else{
            // configure with favored image driver (gd by default)
            Image::configure(array('driver' => 'gd'));
           // set the image width and height for the image
          $newImgName     = "profile" . $userId . ".webp";
          $newImgName2     = "profile" . $userId . "-small.webp";
          $imgDestination = APP_ROOT . "/profile_image/" . $newImgName;
          $imgDestination2 = APP_ROOT . "/profile_image/" . $newImgName2;
          $saveProfileImg = Image::make($imageNameTmp)->resize(120, 90)->save($imgDestination);
          $saveProfileImg2 = Image::make($imageNameTmp)->resize(77, 40)->save($imgDestination2);

Please help me with this problem.

I've tried to change the jquery file I am using and used the CDN instead of the uploaded file but nothing happens still with the same problem I am using image intervention to upload webp images and I am using GD and I checked if the GD is enabled on my server and yes it enabled. I don't know what to do this is the first time I had this type of problem.

It should call the file add_avatar.php?id=6 and the server should response with 200 but the server response with 500 Error.

Mr.Awad
  • 11
  • 8
  • There are probably more details in the logs. An "internal server error" is obviously not very informative. What is the web server and have you looked in the logs? – ficuscr Aug 29 '19 at 16:17

0 Answers0