el codigo que uso es el siguiente:
Código PHP:
<?php
$postback = isset($_POST) ? true : false;
if($postback) {
extract($_POST); // tal vez no sea necesario
$archivos = '';
if(isset($_FILES['archivos'])) { // Si es que subio algun archivo
// $cantidad =count($_FILES["archivos"]);
// echo 'Se enviaron: '.$cantidad.' archivos';
// $cantidad = 0;
foreach($_FILES['archivos']['error'] as $key => $error) { // itera sobre la coleccion de archivos
// $cantidad++;
if($error == UPLOAD_ERR_OK){
echo 'valor $key='.$key."<br />";
}
if($error == upload_err_ok) { // si no hay error
$tmp_name = $_FILES["archivos"]["tmp_name"][$key];
$name = $_FILES["archivos"]["name"][$key];
$name = uniqid('bc').'_'.$name; // Genera un nombre unico para el archivo
move_uploaded_file($tmp_name, $_SERVER['DOCUMENT_ROOT']."./pruebas/imagenes/"); // Guardamos el archivo en una ubicacion
}
}
// echo 'Cantidad de archivos:'.$cantidad;
}
}
?>
<!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>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Multiple Upload</title>
<style type="text/css">
/* mostrar bien los nuevos elementos */
.file{
display:block;
}
span a{
margin-left:1em;
}
input, textarea{
border:3px double #CCC;
background-color:#FAFAFA;
}
</style>
<script type="text/javascript">
var numero = 0;
// Funciones comunes
c= function (tag) { // Crea un elemento
return document.createElement(tag);
}
d = function (id) { // Retorna un elemento en base al id
return document.getElementById(id);
}
e = function (evt) { // Retorna el evento
return (!evt) ? event : evt;
}
f = function (evt) { // Retorna el objeto que genera el evento
return evt.srcElement ? evt.srcElement : evt.target;
}
addField = function () {
container = d('files');
span = c('SPAN');
span.className = 'file';
span.id = 'file' + (++numero);
field = c('INPUT');
field.name = 'archivos[]';
field.type = 'file';
a = c('A');
a.name = span.id;
a.href = '#';
a.onclick = removeField;
a.innerHTML = 'Quitar';
span.appendChild(field);
span.appendChild(a);
container.appendChild(span);
}
removeField = function (evt) {
lnk = f(e(evt));
span = d(lnk.name);
span.parentNode.removeChild(span);
}
</script>
</head>
<body>
<form name="frm" id="frm" action="" method="post" enctype="multipart/form-data">
<dl>
<dt>
<label>Archivos Adjuntos</label>
<a href="#" onclick="addField()">anadir archivo</a>
</dt>
<dd>
<div id="files">
</div>
</dd>
<dd>
<input type="submit" value="Enviar" id="postback" name="postback" />
</dd>
</dl>
</form>
</body>
</html>
el error que me genera es:
Warning: move_uploaded_file(C:/wamp/www/./pruebas/imagenes/) [function.move-uploaded-file]: failed to open stream: No such file or directory in C:\wamp\www\pruebas\Mi_uploader1.php on line 27
alguien puede ayudarme.
gracias de antemano.