Jump to content

error can someone help me imagepng code


mrravee

Recommended Posts

<?php

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];

        // Remove the extension and replace it with .png.

         imagepng(imagecreatefromstring(file_get_contents($_FILES["file"]["tmp_name"] )), "output.png");




       // One method for this is to use the "explode" function with a dot as a delimiter.


// variable we are going to split


  print_r (explode(".",$target_name));



        // Then replace the last part with png and then stick the string back together with "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');


}

 

I have to do this but i get this error: https://ibb.co/mFzxqXL

can anyone help me?

// Remove the extension and replace it with .png.


// One method for this is to use the "explode" function with a dot as a delimiter.

// variable we are going to split:

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

Link to comment
Share on other sites

i need the last step now.

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

 

<?php

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"






        $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');


}

 

Edited by mrravee
Link to comment
Share on other sites

11 minutes ago, gw1500se said:

Please explain why you want to change the file type? That makes no sense to me.

its something what i have to do for internship but i cant find a way how i place this together: replace the last part with png and then stick the string back together with "implode"

Link to comment
Share on other sites

It still makes no sense to be altering the filename extension.  Once you do that most applications will not be able to decipher the file since it won''t be in the format indicated by whatever extension you use.   Think about it - you change in image file name to end with ".txt".  Then when you click on it your text editor tries to open it and all it gets is gibberish.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.