Bonjour,

J'aimerais pouvoir prévisualiser une image chargé depuis mon pc avant l'envoie vers la bdd.

mais je n'arrive toujours pas.

Code php : 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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
<!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>
  <title>News (add - preview)</title>
  <meta http-equiv="content-type" content="text/html; charset=utf-8" />
 
</head>
 
<body>
<?php
 
if ($_POST) {
    @extract($_POST);
}
 
if (IsSet($_POST['add']))
 {
     $target_path = "uploads/";
     $target_path1 = $target_path . basename( $_FILES['fileupload']['name']);
     $target_path2 = $target_path . basename( $_FILES['imgupload']['name']);
 
     if(move_uploaded_file($_FILES['fileupload']['tmp_name'], $target_path1)) {
         $errimg = "The file ".  basename( $_FILES['fileupload']['name'])." has been uploaded";
    } else{
    $errimg .= "There was an error uploading the file, please try again!";
    }
 
    if(move_uploaded_file($_FILES['imgupload']['tmp_name'], $target_path2)) {
         $errimg .= "The file ".  basename( $_FILES['imgupload']['name'])." has been uploaded";
    } else{
    $errimg .= "There was an error uploading the file, please try again!";
    }
    echo $errimg;
 
     // do the insert here
     //$sql = 'INSERT INTO your_table ...';
     echo '<meta http-equiv="refresh" content="2; url=addnews.php" />';
     //header("Location: addnews.php");
}
elseif (IsSet($_POST['prev'])) {
?>
<div style="display:block;">
    <p><b>Preview news</b></p>
    <p><?=$title;?></p>
    <div>
    <table style="flot:left; border : 1px solid #eee;">
        <tbody>
            <tr height="1"></tr>
            <tr>
                <td width="1"></td>
                <td align="center">
                    <img height="200" width="225" align="left" src="<?=$_FILES['fileupload']['tmp_name'];?>" alt="">
                    <img height="200" width="225" align="left" src="<?=$_FILES['linkupload']['tmp_name'];?>" alt="">
                </td>
 
            </tr>
            <tr>
                <td width="1"></td>
                <td align="center"><font size="2" color="#333300"><?=$titleimg;?></font></td>
                <td width="1"></td>
                <td></td>
            </tr>
         </tbody>
    </table>
    </div>
    <span><?=$post;?></span>
    <br />
    <hr color="#0000FF" />
</div>
<?php
}
?>
 
<div style="display:block;">
<form enctype="multipart/form-data" method="post" action="<?=$_SERVER['PHP_SELF']?>">
 
    <p>News title :
    <input type="text" name="title" value="<?=$title;?>" size="40" /></p>
    <p>Post :
    <textarea name="post" rows="10" COLS="40" ><?=$post?></textarea></p>
    <p>Image From PC :
    <input type="file" name="fileupload" /></p>
    <p>Image from link :
    <input type="text" name="linkupload" value="<?=$linkupload;?>"/></p>
    <p>Title of image :
    <input type="text" name="titleimg" value="<?=$titleimg;?>"/></p>
    <p>Title of image :
    <input name="add" type="submit" value="Inzert" />
    <input name="prev" type="submit" value="Preview" /></p>
 
</form>
</div>
</body>
</html>

http://majallati.comli.com/test/preview/addnews.php

Merci d'avance.