0
hello folks I’m developing a real estate site, but I’m still a little layy in php, a friend of mine was helping me , but now he can no longer, is the following the system I want is the following, Let’s say that in my database I have several registered properties and I need to change only the photos of the property and still see the photos I will send to the database and folder before I upload the image. You know like the facebook site when we edit the profile image for example and it shows us the right loaded image. How do I do this.
Note: I want to do the multiple preview, ie preview more than one photo.
<?php
session_start();
if (isset($_SESSION['usuario'])&&isset($_SESSION['logado'])) {
/*
paginas que adiciona fotos no imóvel
*/
//verifico se foi passado o ID do imóvel
if (!isset($_GET['id'])):
//Caso não voltar a pagina
echo '<div class="erro">Operação incorreta</div>';
header('Refresh: 1; ?pag=imoveis_fotos');
else:
$imv_id = $_GET['id'];
endif;
//verifico a quantidade de fotos que existe no imovel
$fotos = new Conexao();
$fotos->ExecSQL("select * from imoveis_fotos where foto_imovel =
'$imv_id'");
//tratando o limite de fotos
$limite = (Sistema::getLimiteFotos() - $fotos->TotalRegistros());
?>
<!--Scripts da biblioteca de upload de imagens-->
<script src="../lightbox/js/jquery-1.11.0.min.js"></script>
<script src="uploadify/jquery.uploadify.min.js"
type="text/javascript"></script>
<link rel="stylesheet" type="text/css"
href="uploadify/uploadify.css">
<div class="texto">
<p id="quem" style="margin-bottom:40px;">Adicionar imagens
</p>
<?php
echo '<center><div style="border:1px solid #000; width:500px;
margin-bottom:50px; font-weight:bolder;">Este imóvel tem ' .
$fotos->TotalRegistros() . ' imagens, o limite é ' .
Sistema::getLimiteFotos() . '.<br>Você pode enviar ainda: ' .
$limite . ' imagem(s)</div></center>';
if($limite < 1):
die('<div id="erro">O limite de imagem deste imóvel esgotou.
Caso queira outras imagens precisa apagar algumas.</div>');
endif;
?>
<script src="uploadify/jquery.uploadify.min.js"
type="text/javascript"></script>
<link rel="stylesheet" type="text/css"
href="uploadify/uploadify.css">
<center> <form>
<div id="queue"></div>
<input id="file_upload" name="file_upload" type="file"
multiple="true">
</form>
<script type="text/javascript">
<?php $timestamp = time();?>
$(function() {
$('#file_upload').uploadify({
'formData' : {
'imovel': '<?php echo $imv_id ;?>',
'timestamp' : '<?php echo $timestamp;?>',
'token' : '<?php echo md5('unique_salt' .
$timestamp);?>'
},
'swf' : 'uploadify/uploadify.swf',
'uploader' : 'uploadify/uploadify.php',
'buttonText': 'Selecionar arquivo',
'uploadLimit': <?php echo $limite ?>,
// depois de terminar
'onQueueComplete' : function(queueData) {
alert(queueData.uploadsSuccessful + ' Imagem (ns)
foram carregadas.');
url = '?pag=imoveis_fotos&id=<?php echo $imv_id
;?>';
$(location).attr("href",url);
} // fim do onQueueComplete
});
});
</script>
</center>
</div>
<a style="background: #73c425;
font-family:'OpenSans', sans-serif;
padding: 5px; margin-left: 10px;
font-size: 15px; text-transform:none;"
href="?pag=imoveis_fotos&id=<?php echo
$imv_id; ?>">Voltar</a>
<?php } else
{header("Location:login.php");} ?>
Thanks, but this code is only to view one image at a time?
– Barbara Gomez
You will have to adapt using Arrays :)
– João Reis