robb28 Posted October 11, 2019 Share Posted October 11, 2019 Hi i am new here, i have to make something but i dont know what to do next can someone help me with this? what i have to do is this: 1. make a class property 2. getCircleFolder Return the Circle folder path. something like this Circles/uniqid 3. getSquareFolder Return the square folder path. something like this Vierkant/uniqid my code: <?php ini_set(‘display_errors’, 1); ini_set(‘display_startup_errors’, 1); error_reporting(E_ALL); class Batch // make a class property { protected $id; public function __construct($id) { $this->id = $id; } getCircleFolder getSquareFolder } // create a new Instance of Folder$circleFolder = new Batch ($id); // gebruik de METHOD getFolder() echo $circleFolder->getPath(); // create a second instance $squareFolder = new Batch ($id); // use the METHOD getFolder () echo $squareFolder->getPath(); Quote Link to comment Share on other sites More sharing options...
gw1500se Posted October 11, 2019 Share Posted October 11, 2019 This should get you started. Quote Link to comment Share on other sites More sharing options...
ginerjm Posted October 11, 2019 Share Posted October 11, 2019 Is this truly a "class" (as in 'classroom') project? Is this how you intend to solve all of your homework? What you have described really is difficult to follow. Why did you not just give us the text of the assignment? Quote Link to comment Share on other sites More sharing options...
robb28 Posted October 11, 2019 Author Share Posted October 11, 2019 it is not something I have to do for school this is just for practice but I have to solve this before I can continue with my assignment and I get stuck on with this piece... this is what i have to do: The way it is made now, we cannot logically output the made zip, nor is it convenient to put hundreds of files in an upload since we can run into a timeout. To solve this, let's upload the file into chunks and convert it to png, and save the "batch" id in a php session First create the 2 classes, test them and then implement them. but im stuck here: make function getCircleFolder Return the Circle folder path. example this Circles/uniqid make function getSquareFolder Return the square folder path. example this Vierkant/uniqid my other file with code: include 'helpers.php'; include 'batch.php'; include 'file.php'; $id = uniqid(); $upload_files[] = [ 'square' => $destination . '/' . $_FILES['file']['name'][$i], 'circle' => $locatie . '/' . topng ($_FILES['file']['name'][$i]) ]; print_r ($upload_files); new code: <?php ini_set('display_errors', 1); ini_set('display_startup_errors', 1); error_reporting(E_ALL); class Batch { protected $id; // De constructor public function __construct($id) { $this->id = $id; } public function getCircleFolder() { } public function getSquareFolder() { } // maak een nieuwe INSTANTIE van Folder aan $circleFolder = new Batch ($id); // gebruik de METHOD getFolder() echo $circleFolder->getPath(); // maak een tweede instantie aan $squareFolder = new Batch ($id); // gebruik de METHOD getFolder() echo $squareFolder->getPath(); Quote Link to comment Share on other sites More sharing options...
gw1500se Posted October 11, 2019 Share Posted October 11, 2019 (edited) No you're stuck at the basics. You have to upload the files either way so breaking it up in chunks changes nothing other than making it more complicated. The chunks would need to be reassembled into files so it would still be uploading the same volume of data. What does the client side code look like that breaks it into chunks? From a PHP perspective, here is no timeout issue for uploading files unless the client stops. In that case the client can simply resume where it left off when it reconnects but that is mostly a client side issue. There may need to be some PHP code added to handle a resume but without more information it would be hard to say what (probably a session list if the successful uploads). Edited October 11, 2019 by gw1500se Quote Link to comment Share on other sites More sharing options...
ginerjm Posted October 12, 2019 Share Posted October 12, 2019 Good luck. I don't understand anything you said in post #2 Quote Link to comment Share on other sites More sharing options...
robb28 Posted October 16, 2019 Author Share Posted October 16, 2019 i got a problem i want to get my .zip file in the folder circles but its not working. maybe someone knows this: The error: https://ibb.co/RjCtP3w my code <?php ini_set('display_errors', 1); ini_set('display_startup_errors', 1); error_reporting(E_ALL); class Batch { protected $id; // De constructor public function __construct($id) { $this->id = $id; return $this; } public function getCircleFolder() { return "circles/$this->id/"; } public function getSquareFolder() { return "squares/$this->id/"; } public function ensureFoldersExist() { createDirectory($this->getCircleFolder()); createDirectory($this->getSquareFolder()); return null; } public function toZip() { $this->ensureFoldersExist(); $obj_zip = new ZipArchive(); $result = $obj_zip->open($this->getCircleFolder().$this->id.".zip", (ZipArchive::CREATE | ZipArchive::OVERWRITE)); if ($result != TRUE) { //print('Failed with code %d', $result) } else { $arr_options = array('add_path' => $this->getCircleFolder(), 'remove_all_path' => TRUE); $obj_zip->addGlob('*.png', GLOB_BRACE, $arr_options); $obj_zip->close(); } } } Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.