Bonjour,
je voudrais connaître comment je peux modifier(remplacer) une images dans ma base des données
DB:animaldata
abdate_img.php
Code sql : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7 CREATE TABLE IF NOT EXISTS `animaldata` ( `ano` int(5) NOT NULL, `aname` varchar(200) NOT NULL, `adetails` text NOT NULL, `aphoto` longblob NOT NULL, `aphototype` varchar(200) NOT NULL ) ENGINE=MyISAM AUTO_INCREMENT=28 DEFAULT CHARSET=utf8 COMMENT='Animal Information Table';
Merci.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43 <?php $conn = mysql_connect("localhost","root",""); if(!$conn){ echo mysql_error(); } $db = mysql_select_db("imagestore",$conn); if(!$db){ echo mysql_error(); } if (isset($_POST['submit'])) { $aname = $_POST['num']; $aphoto = addslashes (file_get_contents($_FILES['img']['tmp_name'])); $image = getimagesize($_FILES['img']['tmp_name']);//to know about image type etc $imgtype = $image['mime']; $q =mysql_query("UPDATE animaldata set aphoto='$aphoto',aphototype='$imgtype' where ano ='$aname'"); echo "goooooood"; } else { echo "not good"; } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Untitled Document</title> </head> <body> <form action="abdate_img.php" method="post"> <p> <input name="num" type="text" /> </p> <p> <input name="img" type="file" /> <label> <input type="submit" name="Submit" value="Submit" /> </label> </p> </form> </body> </html>
Partager