You are just sending an image!
My Form
<form role="form" method="post" action="./?action=addmult" enctype="multipart/form-data">
<div class="form-group">
<label>Imagen (480x480)</label>
<input type="file" name="image" multiple="">
</div>
<div class="form-group">
<label>Pasta</label>
<input type="text" name="folder" class="form-control" placeholder="Pasta">
</div>
<button type="submit" class="btn btn-primary">Enviar</button>
I'm using the Class Upload !
My code.
if(isset($_FILES["image"])){
$image=new Upload($_FILES["image"]);
if($image->uploaded){
$folder = 'teste';
$new = mkdir($target_dir . $folder . "/");
$image->Process("storage/images/".$folder);
if($image->processed){
$img = new ImageData();
$p->title = $_POST["title"];
$p->content = $_POST["content"];
$img->src = $image->file_dst_name;
$img->user_id=$_SESSION["user_id"];
$imgx=$img->add();
}
}
}
Core::redir("./?view=galery");
Attempt
if(isset($_FILES["image"])){
$handle=new Upload($_FILES["image"]);
$files = array();
foreach ($_FILES['image'] as $k => $l) {
foreach ($l as $i => $v) {
if (!array_key_exists($i, $files))
$files[$i] = array();
$files[$i][$k] = $v;
}
}
foreach ($files as $file) {
$handle = new Upload($file);
if($handle->uploaded){
$folder = $_POST["folder"];
$new = mkdir($target_dir . $folder . "/");
$handle->Process("storage/images/".$folder);
if($handle->processed){
$img = new ImageData();
$p->title = $_POST["title"];
$p->content = $_POST["content"];
$img->src = $image->file_dst_name;
$img->user_id=$_SESSION["user_id"];
$imgx=$img->add();
echo 'OK';
} else {
echo 'Error: ' . $handle->error;
}
} else {
echo 'Error: ' . $handle->error;
}
unset($handle);
}
Core::redir("./?view=galery");