Código PHP:
<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, title: $("#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="title" name="title" />
<a href="javascript:$('#file_upload').uploadifyUpload();">Cargar Imagenes</a>
</form>
Código PHP:
'onComplete': function(event, ID, fileObj, response, data) {
$.post("uploadify.php",{name: fileObj.name, title: $("#title").val()}, function(info) {
alert(info); // alert UPLOADED FILE NAME
});
},