-1
Just sending a picture!
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");
Trying
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");
Upload and Imagedata classes are not native, so it is impossible answer your question, because we don’t even know if this is a framework or code and therefore we don’t know the basics to be able to provide any help.
– Guilherme Nascimento
you, should not have understood the information about ! Just sending an image! where is the Wally ?
– Carlos Coelho
Without knowing the code we have no way to say exactly what is the correct (or most appropriate) use for the upload, after all if it is a personal code of yours (I refer to the classes) only you would be able to say, If it is a popular Framework then only if you tell what it is and what its version is. PS: Just to warn you, I didn’t give the downvote.
– Guilherme Nascimento
everything works imagedata and Upload what happens that it is not sending multiple images and only one image is sent ! folder creation , picture uploading all ok! as it comes to only one class as in the link above it believe , that do not need
– Carlos Coelho
An array is coming in
$_FILES["image"]
?– Max Rogério
No! There’s nothing enough.
– Carlos Coelho