Bonjour,
J'aimerais pouvoir prévisualiser une image chargé depuis mon pc avant l'envoie vers la bdd.
mais je n'arrive toujours pas.
http://majallati.comli.com/test/preview/addnews.php
Merci d'avance.
Modifié par apt (27 Mar 2011 - 15:14)
J'aimerais pouvoir prévisualiser une image chargé depuis mon pc avant l'envoie vers la bdd.
mais je n'arrive toujours pas.
<!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.
Modifié par apt (27 Mar 2011 - 15:14)