-4
Hello,
I created a code where I simply upload multiple images.
But I’m not able to enter the values of the urls 'im/pd/'. $file_name_new;
of the variable $file_destination
in the comic book.
At DB I have..
User_id | img1 | img2 |
What should I include in the code so that urls
are inserted in the database and also how to save the images in the folder.
Code:
//images function
$ads_file = mysqli_real_escape_string($con, sanitize($_FILES['img_file']['name'][0]));
if(!empty($ads_file)) {
$files = $_FILES['img_file'];
$allowed = array('png', 'jpg', 'jpeg', 'gif');
foreach($files['name'] as $position => $file_name) {
$file_tmp = $files['tmp_name'][$position];
$file_size = $files['size'][$position];
$file_error = $files['error'][$position];
$file_ext = explode('.', $file_name);
$file_ext = strtolower(end($file_ext));
if(in_array($file_ext, $allowed)) {
if($file_error === 0) {
if($file_size <= 4097152) {
$file_name_new = uniqid('', true) . '.' . $file_ext;
$file_destination = 'im/pd/'. $file_name_new;
$uploaded[$position] = $file_destination;
//define o caminho para o folder e para DB
} else {
$errors[] = "
<div class='alert warning'>
<span class='closebtn'>×</span>
<strong><i class='fas fa-file-excel'></i></strong> Esta imagem é demasiado grande.
</div>";
}
} else {
$errors[] = "
<div class='alert warning'>
<span class='closebtn'>×</span>
<strong><i class='fas fa-plug'></i></strong> Falha ao efetuar o upload. Tente novamente...
</div>";
}
} else {
$errors[] = "
<div class='alert warning'>
<span class='closebtn'>×</span>
<strong><i class='fas fa-file-excel'></i></strong> Ficheiro desconhecido, tente outro.
</div>";
}
}
}
New Error
I used the variables you gave me in relation to
$praBanco .=" '".$file_destination."', ";
for ($x = 1; $x <=$quantColunas; $x++) {
$colunas.=" ads_image_".$x." = ";
}
$praBanco = substr($praBanco,0,-1);
$colunas = substr($colunas,0,-1);
$columns and $praBanco
The problem is that... It does not update because I think something is wrong regarding the update entry.
$smtp_process = "UPDATE public_ads SET ads_title = '$ads_title', ads_content = '$ads_content', ads_price = '$ads_price', edit_attempts = edit_attempts + 1, $colunas = '$praBanco' WHERE ads_id = '$editor_id'";
$smtp_request_query = $con->query($smtp_process);
But... it does not update or show errors...
I think it’s about this: $columns = '$praBanco'
The goal is that it add in the Database the path of the amount of images uploaded. As was done in INSERT, now click UPLOAD.
Liked, very good, but as I do now for it MOVE the 2 IMAGES to the Folder?
– user21312321
Could you help me @Leo Caracciolo
– user21312321
Hey Friend... eheheh i’ve got one mroe Question to Ask u... i Did a update query.... but is not updating... can you Please check my code...
– user21312321
$smtp_process = "UPDATE public_ads SET ads_title = '$ads_title', ads_content = '$ads_content', ads_price = '$ads_price', edit_attempts = edit_attempts + 1, $colunas = '$praBanco' WHERE ads_id = '$editor_id'";
 $smtp_request_query = $con->query($smtp_process);
– user21312321
@user21312321, Ask a new Question and Tell me here what the link in the post is. To show you how to do through comment gets difficult. Ask a new question and tell me here which link of the post.
– user60252
Sorry. I didn’t answer. That’s right, I have a part of the code that is exactly the same as that of sending multiple images, instead of being in INSERT will be in an UPDATE...
– user21312321
@user21312321, then ask a new question by posting the code you put in the comment above that I give you a solution because here with comment it is difficult and unintelligible the answer. As soon as you post the question leave a comment here
– user60252
Leo Caracciolo, I sent the bug up New Error, help sff.
– user21312321
@user21312321 , ask new question for this post do not get confused! Puts what you had done as an answer that I edit to be in agreement
– user60252
Simply, as you did before... Add the Images in INSERT... press UPLOAD.. is just set the variables inside the UPLOAD.... Can help?
– user21312321
Yes, but ask a new question, it costs nothing to do right!!!!!!
– user60252
Of course, this one https://answall.com/questions/291503/php-upload-errors
– user21312321