PHP PDO Multiple image INSERT

fecapeluda

I'm pretty new at this and getting a hard time building a very simple script for image upload. I have a input file called txtfoto if I insert a single record this works great, but what I trying to do is insert the values of 4 input files called txtfoto[] at once. I'm sure that something is wrong or missing in my PHP code so any help i'll great.

HTML:

<label>Imagen: <input name="txtfoto[]"  type="file">
<input name="txtfoto[]"  type="file">
<input name="txtfoto[]"  type="file">
<input name="txtfoto[]"  type="file"></label>

PHP:

    $file = $_FILES["txtfoto"]["name"][$key]

mysql sentence:

for ($key=0; $key<count($_FILES["txtfoto"]["name"][$key]); $key++){
$sql = "INSERT INTO imagenes (nombre,foto) VALUES (:nombre,:foto)";
$result = $db->prepare($sql);
$result->execute(array(':nombre' => $txtnombre, ':foto' => $file));}
}
arif_suhail_123
for ($key=0; $key<count($_FILES["txtfoto"]["name"]); $key++){
$file = $_FILES["txtfoto"]["name"][$key];
$sql = "INSERT INTO imagenes (nombre,foto) VALUES (:nombre,:foto)";
$result = $db->prepare($sql);
$result->execute(array(':nombre' => $txtnombre, ':foto' => $file));}

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Insert multiple rows using PHP PDO

From Dev

PHP, PDO, MySQL - Multiple INSERT vulnerable to injection?

From Dev

how to Insert multiple arrays with multiple rows into MySQL using PHP PDO

From Dev

What is the best way to insert multiple rows in PHP PDO MYSQL?

From Dev

Insert multiple values via PHP PDO into MySQL database

From Dev

php pdo select multiple rows and insert to other table with LIMIT

From Dev

PDO insert not inserting with multiple values

From Dev

Insert post with multiple tags in PDO

From Dev

Pdo multiple row insert issue

From Dev

pdo, insert php object to database

From Dev

Insert PHP PDO via AJAX

From Dev

Insert PHP PDO via AJAX

From Dev

check pdo php insert success

From Dev

Insert image into sql server db with pdo

From Dev

Insert image into sql server db with pdo

From Dev

multiple PDO insert with single statement not working

From Dev

From Textarea to multiple value insert using PDO

From Dev

PDO Insert multiple checkbox values in Mysql

From Dev

PHP PDO Multiple Prepare Statement

From Dev

PHP PDO Multiple Table join

From Dev

Insert record PHP/PDO throwing error

From Dev

PHP PDO Insert Only Inserting First Character

From Dev

PHP,PDO,MySQLi function dont insert to database

From Dev

PDO Insert operation using PHP and MYSQL not working

From Dev

PHP; PDO; MySQL; INSERT query not taking input

From Dev

PHP; PDO; MySQL INSERT query with drop down

From Dev

php pdo insert datas using function

From Dev

PHP PDO insert statement not going through

From Dev

PHP PDO: Insert working without attributes