Código PHP:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>imagenes</title>
<link rel="stylesheet" type="text/css" href="uploadify/uploadify.css">
<style>
#lista {
background-color: #FFF;
border-radius: 3px;
box-shadow: 0 1px 3px rgba(0,0,0,0.25);
width: 390px;
height: 300px;
margin-bottom: 10px;
overflow: auto;
padding: 5px 10px;
}
#cajafotos {
background-color: #FFF;
border-radius: 3px;
box-shadow: 0 1px 3px rgba(0,0,0,0.25);
width: 500px;
height: 300px;
margin-bottom: 10px;
overflow: auto;
padding: 5px 10px;
}
</style>
<?php
if(isset($_GET['album'])){
$id_album=$_GET['album'];
?>
<script type="text/javascript" src="uploadify/jquery-1.4.2.min.js"></script>
<script type="text/javascript" src="uploadify/swfobject.js"></script>
<script type="text/javascript" src="uploadify/jquery.uploadify.v2.1.4.min.js"></script>
<script type="text/javascript">
$(function() {
$('#file_upload').uploadify({
'uploader' : 'uploadify/uploadify.swf',
'script' : 'uploadify/uploadify.php',
'cancelImg': 'uploadify/cancel.png',
'queueID' : 'lista',
'wmode' : 'transparent',
'folder' : 'galeria',
'buttonText': 'Seleccionar',
'fileDesc' : 'Solo .jpg',
'fileExt' : '*.jpg',
'multi' : true,
'auto' : false,
'onComplete': function(event, ID, fileObj, response, data) {
$.post("uploadify.php",{name: fileObj.name, id_A: $("#title").val()}, function(info) {
alert(info); // alert UPLOADED FILE NAME
});
},
'onSelect' : function(event,ID,fileObj) {
var filter = /(.jpg|.jpeg)/;
// utilizamos test para comprobar si el parametro valor cumple la regla
if(!(filter.test(fileObj.type.toLowerCase()))){
alert('solo se aceptan archivos .jpg,jpeg');
return false;
}/*if*/
},
});
});
</script>
</head>
<body>
<center>
<div id="lista"></div>
<form id="form1" name="form1" action="">
<input type="file" name="file_upload" id="file_upload" /><br />
<input type="hidden" id="id_A" name="id_A" value="<?php echo $id_album?>" />
<a href="javascript:$('#file_upload').uploadifyUpload();">Cargar Imagenes</a>
</form>
<br/><br/>
<div id="cajafotos"></div>
</center>
<?php }else{
header("location:album.php");
}?>
</body>
</html>