config.php
Código PHP:
<?php
// Configuraciones de la subida
$uploadAUDIOdir = "./directorio/".$_SESSION['nickname']."/";
$a = array (
"á","é","í","ó","ú",
"Á","É","Í","Ó","Ú",
"ñ","<",">","ç","Ç",
"`","´","'","¡","!","?","¿",
"@","#","$","%","&","/","=",
);
$b = array (
"a","e","i","o","u",
"A","E","I","O","U",
"n","","","c","C",
"","","","","","","",
"","","","","","","",
);
$nombre = str_replace($a, $b, $_FILES['uploadfile']['name']);
// Sacamos caracteres especiales al archivo subido por si es un script malicioso
$nombre = htmlspecialchars($nombre);
// Le doy un valor RANDOM al nombre del archivo para evitar errores
$randomtext = substr(md5(uniqid(rand())),0,6);
$file = $uploadAUDIOdir.$randomtext.'_'.$nombre;
$size=$_FILES['uploadfile']['size'];
if($size>8388608)
{
echo "Pesa más de 8 MBs";
unlink($_FILES['uploadfile']['tmp_name']);
exit;
}
if (move_uploaded_file($_FILES['uploadfile']['tmp_name'], $file)) {
echo "Subida con éxito: $file";
} else {
echo "error ".$_FILES['uploadfile']['error']." --- ".$_FILES['uploadfile']['tmp_name']." %%% ".$_FILES['uploadfile']['name']."($size)";
}
?>
Código PHP:
$(function(){
$('#swfupload-control').swfupload({
upload_url: "js/config.php",
file_post_name: 'uploadfile',
file_size_limit : "8192",
file_types : "*.mp3;*.wma",
file_types_description : "Archivos de Audio",
file_upload_limit : 2,
flash_url : "js/swfupload/swfupload.swf",
button_image_url : 'js/swfupload/wdp_buttons_upload_114x29.png',
button_width : 114,
button_height : 29,
button_placeholder : $('#button')[0],
debug: true
})
.bind('fileQueued', function(event, file){
var listitem='<li id="'+file.id+'" >'+
'Archivo: <em>'+file.name+'</em> ('+Math.round(file.size/1024)+' KB) <span class="progressvalue" ></span>'+
'<div class="progressbar" ><div class="progress" ></div></div>'+
'<p class="status" >Pending</p>'+
'<span class="cancel" > </span>'+
'</li>';
$('#log').append(listitem);
$('li#'+file.id+' .cancel').bind('click', function(){
var swfu = $.swfupload.getInstance('#swfupload-control');
swfu.cancelUpload(file.id);
$('li#'+file.id).slideUp('fast');
});
// start the upload since it's queued
$(this).swfupload('startUpload');
})
.bind('fileQueueError', function(event, file, errorCode, message){
alert('Archivo: '+file.name+' excede el tamaño permitido.');
})
.bind('fileDialogComplete', function(event, numFilesSelected, numFilesQueued){
$('#queuestatus').text('Archivos seleccinado(s): '+numFilesSelected+' / Podés subir: '+numFilesQueued);
})
.bind('uploadStart', function(event, file){
$('#log li#'+file.id).find('p.status').text('Subiendo... Espere porfavor.');
$('#log li#'+file.id).find('span.progressvalue').text('0%');
$('#log li#'+file.id).find('span.cancel').hide();
})
.bind('uploadProgress', function(event, file, bytesLoaded){
//Show Progress
var percentage=Math.round((bytesLoaded/file.size)*100);
$('#log li#'+file.id).find('div.progress').css('width', percentage+'%');
$('#log li#'+file.id).find('span.progressvalue').text(percentage+'%');
})
.bind('uploadSuccess', function(event, file, serverData){
var item=$('#log li#'+file.id);
item.find('div.progress').css('width', '100%');
item.find('span.progressvalue').text('100%');
var pathtofile='<a href="uploads/'+file.name+'" target="_blank" >view »</a>';
//item.addClass('success').find('p.status').html('Subido con éxito | '+pathtofile);
item.addClass('success').find('p.status').html('Subida con éxito '+file.name+' ahi');
})
.bind('uploadComplete', function(event, file){
// upload has completed, try the next one in the queue
$(this).swfupload('startUpload');
})
});
y mi correspondiente upload.php:
Cita:
<script type="text/javascript" src="js/swfupload/swfupload.js"></script>
<script type="text/javascript" src="js/jquery.swfupload.js"></script>
<script type="text/javascript" src="js/config.js"></script>
<div id="swfupload-control" align="left">
<p align="center">Podés subir 2 canciones(.mp3, .wma) que no pesen más de 8MBs cada una.</p>
<input type="button" id="button" align="middle" />
<p id="queuestatus" align="left"></p>
<ol id="log" align="left"></ol>
</div>
<script type="text/javascript" src="js/jquery.swfupload.js"></script>
<script type="text/javascript" src="js/config.js"></script>
<div id="swfupload-control" align="left">
<p align="center">Podés subir 2 canciones(.mp3, .wma) que no pesen más de 8MBs cada una.</p>
<input type="button" id="button" align="middle" />
<p id="queuestatus" align="left"></p>
<ol id="log" align="left"></ol>
</div>
Subiendo:
http://img685.imageshack.us/i/sinttuloam.jpg/
Bien, voy al directorio, NADA, absolutamente NADA. Qué podrá ser?