thanks for helping it works now i got 1 more question:
i have to use ajax i think the (post methode) what i try to do is the lane 1 2 3 4 is now on 1 1 5 2 but what i want is that if i press on one button that it will be stored on the button I last clicked on. do you know how to use this and where i have to put it in de code?
//jsonfile = '[{"lane 1":"1","lane 2":"1","lane 3":"5","lane 4":"2"}]';
var jsonRequest = new XMLHttpRequest();
jsonRequest.onreadystatechange = function () {
if (jsonRequest.readyState == 4 && jsonRequest.status == 200) {
var initialstate = JSON.parse(jsonRequest.responseText);
setLaneStates(initialstate);
console.log('Done loading JSON data');
} else {
console.log('Failed to get JSON data');
}
}
jsonRequest.open( "GET", "data.json", true);
jsonRequest.send( null );
Hi Everyone,
i need some help how can i save this jsonfile to the webserver?
my code
// Load initial values from JSON 'file'
jsonfile = '[{"lane 1":"1","lane 2":"1","lane 3":"5","lane 4":"2"}]';
var initialstate = JSON.parse(jsonfile);
setLaneState("lane1",initialstate[0]['lane 1'])
setLaneState("lane2",initialstate[0]['lane 2'])
setLaneState("lane3",initialstate[0]['lane 3'])
setLaneState("lane4",initialstate[0]['lane 4'])
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();
}
}
}
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();
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();
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.