Me he bajado un applet de java que permite múltiples uploads www.jupload.biz
Ese applet tira de un .php para subir los archivos a una carpeta de mi servidor que se llama temp.
El caso es que mi web va con usuarios registrados y lo que quiero hacer es que los archivos de usuario con ID 1 se inserten en la carpeta temp/1, los del usuario ID 2 en la carpeta temp/2, etc...
Este es el código del php que hace subir las imágenes
Código PHP:
<?php
/*
* JUpload php example
* saves all uploaded files to the temp/ directory
* see [url]http://www.haller-systemservice.net/jupload/[/url]
* info@@haller-systemservice.net
*´
*/
/*
* Iterate over all received files.
* PHP > 4.2 / 4.3 ? will save the file information into the
* array $_FILES[]. Before these versions, the data was saved into
* $HTTP_POST_FILES[]
*/
foreach($_FILES as $tagname=>$objekt)
{
// get the temporary name (e.g. /tmp/php34634.tmp)
$tempName = $objekt['tmp_name'];
// get the real filename
$realName = $objekt['name'];
// where to save the file?
$target = './temp/' . $realName;
// print something to the user
echo "<br>Processing file $realName...\n";
flush();
// move the file to the target directory
move_uploaded_file($tempName,$target);
/* This is a sample from Wilson
* which will generate thumbnails from
* the uploaded files. Use it, if you like.
*/
/*
$src_img = imagecreatefromjpeg($target);
$origw=imagesx($src_img);
$origh=imagesy($src_img);
$new_w = '150';
$ratio=$origh*$new_w;
$new_h=$ratio/$origw;
$dst_img = imagecreatetruecolor($new_w,$new_h);
imagecopyresized($dst_img,$src_img,0,0,0,0,$new_w,$new_h,imagesx
($src_img),imagesy($src_img));
imagejpeg($dst_img, $thumb_target);
*/
// end of iteration
echo "next file...\n";
flush();
}
/*
* This is optional.
* send error response to jupload
* format depends on API version of PHP
*/
switch(php_sapi_name())
{
case 'cgi':
case 'cgi-fcgi':
$sz_htstatus = 'Status: ';
break;
default:
$sz_htstatus = 'HTTP/1.0: ';
break;
}
/*
* Let's generate an error message for JUpload
*/
// everything is okay - default message
$sz_message='200 JUpload works great';
// if we got no files, show error message to user
if (count($_FILES) == 0)
$sz_message='406 No files uploaded';
// now, send the header to JUpload applet
header($sz_htstatus.$sz_message);
// print debug code
//echo "<br><pre>_FILES:\n";
//print_r($_FILES);
//echo "</pre>\n";
flush();
?>
Código PHP:
// where to save the file?
$target = './temp/$id' . $realName;
Gracias
PD Tened en cuenta por favor que no soy experto en PHP