Exemplo n.º 1
0
            break;
        case "png":
            if (!imagepng($image_p, $location)) {
                throw new RuntimeException('Failed to move uploaded file.');
            }
            break;
        default:
            throw new RuntimeException("Error Bad Extention");
            break;
    }
    imagedestroy($rImg);
    imagedestroy($image_p);
    /*
          if ( !move_uploaded_file( $_FILES["upfile"]["tmp_name"], $location) ) {
            throw new RuntimeException('Failed to move uploaded file.');
          }
    */
    $util = new Util();
    $fileName .= '.' . $ext;
    $imgupload = new ImageUpload();
    $imgupload->saveimage($_SESSION['user_id'], $fileName);
    $message = 'File is uploaded successfully.';
} catch (RuntimeException $e) {
    $message = $e->getMessage();
    $status = 500;
    $location = '';
}
header("HTTP/1.1 " . $status . " " . $status_codes[$status]);
$response = array("status" => $status, "status_message" => $status_codes[$status], "message" => $message, "location" => $location);
echo json_encode($response);
die;