I am trying to test how to upload a pic on my wamp database but I have a of “Undefined index:Pic” error. Could you please help me? Thank you!
Here is the code of my formulaire:
<form action="PicPost.php" method="post" enctype="multipart/form-data">
<p>
Formulaire d'envoi de fichier :<br />
<input type="file" name="Pic" /><br />
<input type="submit" value="Post the pic" />
</p>
</form>
And here is the file that should treat it:
<?php
try
{
$bdd = new PDO('mysql:host=localhost;dbname=db', 'root', '');
}
catch (Exception $e)
{
die('Erreur : ' . $e->getMessage());
}
$req = $bdd->prepare('INSERT INTO picdb (Picture)
VALUES(?)');
$req->execute(array($_POST['Pic']));
?>
Adapt This To Your Environment
Select Pic To Upload:
insert.php
Here you have a file uploader.