Error php code image jpg to png

i need to do this: //replace the last part with png and then stick the string back together with “implode”

can anyone help me?

ini_set(‘display_errors’, 1);
ini_set(‘display_startup_errors’, 1);
error_reporting(E_ALL);

include ‘helpers.php’;

$foldername = uniqid();

$destination = “vierkant/$foldername”;
$locatie = “circles/$foldername”;

createDirectory($locatie);
createDirectory($destination);

$upload_files = [];

for ($i = 0; $i < count($_FILES[‘file’][‘name’]); $i++) {
move_uploaded_file(
$_FILES[‘file’][‘tmp_name’][$i],
$destination . ‘/’ . $_FILES[‘file’][‘name’][$i]
);

    $target_name = $_FILES['file']['name'][$i];

    // Haal de extensie eraf en vervang hem door .png.
    $part = explode(".",$target_name);

    end($part);
    $key = key($part);
    reset($part);
    $part [$key] = "png";

print_r ($part);

    // replace the last part with png and then stick the string back together with "implode""implode"

   
   
   
   
   
    $upload_files[] = [
        'square' => $destination . '/' . $_FILES['file']['name'][$i],
        'circle' => $locatie . '/' . $_FILES['file']['name'][$i],
    ];
}

foreach ($upload_files as $loopdata) {
print_r($loopdata[‘circle’]);

    toCircle($loopdata['square'],$loopdata['circle'],'450');

}

Just changing the extension does not make it that type.

1 Like

thanks it works now i need the last thing code to fix replace the last part with png and then stick the string back together with “implode” :blush:

Sponsor our Newsletter | Privacy Policy | Terms of Service