# Kijken of er gepost wordt
if($_SERVER['REQUEST_METHOD'] == 'POST')
{
# Values trimmen
$Value = trim($Value);
# Array sorteren
foreach($_POST['veld'] as $Key => $Value)
{
# Kijken of er lege values zijn (DIT KAN OOK NOG WAT BETER)
if($Value == '')
{
# Lege value(s) uit de array halen
unset($_POST['veld'][$Key]);
}
}
# Array met de nieuwe waarden
$newArray = array_values($_POST['veld']);
# Kijken of er wel values zijn ingevuld
if(count($newArray) == 0)
{
# Geen values ingevuld
echo 'Er zijn geen values ingevuld.';
}
else
{
# Array sorteren om de nieuwe values te laten zien
foreach($newArray as $Results)
{
echo $Results.'</br>';
}
}
}
?>
Let wel op, kan allemaal wat beter (Ben zelf geen Pro in Array's).
# Array sorteren
foreach($_POST['file_upload'] as $Key => $Value)
{
# Kijken of er lege values zijn (DIT KAN OOK NOG WAT BETER)
if($Value == '')
{
# Lege value(s) uit de array halen
unset($_POST['file_upload'][$Key]);
}
}
# Array met de nieuwe waarden
$newArray = array_values($_POST['file_upload']);
# Kijken of er wel values zijn ingevuld
if(count($newArray) == 0)
{
# Geen values ingevuld
echo 'Er zijn geen values ingevuld.';
}
else
{
# Array sorteren om de nieuwe values te laten zien
foreach($newArray as $Results)
{
echo $Results.'</br>';
}
}
if($object->save()) {
$session->message("Blog is toegevoegd op de site");
redirect_to('lijst_blog.php'); //listphotos
} else {
// Fail
$message = join("<br/>", $object->errors);
}
}
?>
Alleen zorgt $object->save() ervoor dat alles wordt verdeeld als enkel bestand.
Hier begint het voor mij vanwege weinig ervaring nog iets te duizelen met omschakkelen.
<?php
// Pass in $_FILE(['uploaded_file']) as an argument
public function attach_file($file) {
// Perform error checking on the form parameters.
if(!$file || empty($file) || !is_array($file)) {
// Error: nothing uploaded or wrong argument usage
$this->error[] = "No file was uploaded";
return false;
// Set object attributes to the form parameters.
$this->id = $file['id'];
$this->temp_path = $file['tmp_name'];
$this->filename = basename($file['name']);
$this->type = $file['type'];
$this->size = $file['size'];
// Dont worry about saving anything to the database yet
return true;
}
}
public function save() {
// A new record wont have an id yet
if(isset($this->id))
{
// Really just to update the caption
$this->update();
}
else
{
/////// Make sure there are no errors
// Cant save if there pre-existing errors
if(!empty($this->errors))
{
return false;
}
// Make sure the caption is not to long for DB
if(strlen($this->caption) > 50)
{
$this->errors[] = "De ondertitel van de foto is langer dan 50 tekens.";
return false;
}
// Cant save without filename and temp location
if(empty($this->filename) || empty($this->temp_path))
{
$this->errors[] = "Locatie bestand is niet beschikbaar.";
return false;
}
// Make sure a file doesn't already exist in the target location
if(file_exists($this->filename))
{
$this->errors[] = "Het bestand {$this->filename} bestaat al.";
return false;
}
######################################
# Maak een thumbnail #
######################################
$width = 150;
$height = 100;
// Content type
header('Content-type: image/jpeg');
// Get new dimensions
list($width_orig, $height_orig) = getimagesize($this->temp_path);//$target_path gaf rare tekens
// Send the image
header('Content-type: image/png');
//--- upload image
// als je deze uitzet wordt het zwart en 5.28kb ipv 26kb
imagejpeg($tn, $save_for_blog, 92); // max. kwaliteit
imagedestroy($tn);
// Save a corresponding entry to the database
if($this->create())
{
// We are done with temp_path, the file isnt there anymore
unset ($this->temp_path);
return true;
}
}
}
?>
Sorry voor de lap.
Maar misschien kun je me een goede richting op duwen.