Jump to content

Recommended Posts

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();

 

Link to comment
https://forums.phpfreaks.com/topic/309354-need-help-with-my-code/
Share on other sites

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();

 

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 by gw1500se

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();
        }
    }
}

 

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.