Jump to content

mrravee

New Members
  • Posts

    7
  • Joined

  • Last visited

mrravee's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. 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"
  2. 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'); }
  3. <?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"
  4. One more question I put my code in $ files because this code had to be in the array so that you can see which picture is in the folders after the upload. code: $ destination. “/”. $ _FILES [‘file’] [‘name’] [$ i]; now I have a problem the $i with $files does not work because I have not linked it yet in the code below I have no idea how to do this I heard something with element in aray can anyone help me? the full code <?php ini_set(‘display_errors’, 1); ini_set(‘display_startup_errors’, 1); error_reporting(E_ALL); include ‘helpers.php’; $foldername = uniqid(); $destination = “vierkant/$foldername”; //Check if the directory already exists. if(!is_dir($destination)){ //Directory does not exist, so lets create it. mkdir($destination, 0755, true); } $files = $destination . ‘/’ . $_FILES[‘file’][‘name’][$i]; for ($i = 0; $i < count($_FILES[‘file’][‘name’]); $i++) { move_uploaded_file( $_FILES[‘file’][‘tmp_name’][$i], $destination . ‘/’ . $_FILES[‘file’][‘name’][$i] ); }
  5. I had to make a code that automatically creates a folder and in that folder had to come my photo that I was going to upload, That works now. But now I have to make a code that that you can see which photos are in the folder and that has to be done automatically. I have my code here I was told that I have to do something with an array, but I can't figure it out can someone help me? ?php ini_set(‘display_errors’, 1); ini_set(‘display_startup_errors’, 1); error_reporting(E_ALL); include ‘helpers.php’; $foldername = uniqid(); $destination = “vierkant/$foldername”; //Check if the directory already exists. if(!is_dir($destination)){ //Directory does not exist, so lets create it. mkdir($destination, 0755, true); } for ($i = 0; $i < count($_FILES[‘file’][‘name’]); $i++) { move_uploaded_file( $_FILES[‘file’][‘tmp_name’][$i], $destination . ‘/’ . $_FILES[‘file’][‘name’][$i] ); }
×
×
  • 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.