Era per non postare 1000 righe di codice...
in realta' il problema sta proprio nelle due righe che ho scritto prima...
comunque...
questa e' la pagina uploadpage.php alla quale passo il valore di $_POST['url'] da un form.
<?
$uploaddir = ("../images/".$_POST['url']);
//this many file upload fields
$fields = 6;
//file accept filter 1 for on, 0 off
$acceptfilter = 1;
//acceptable file types (see www.w3schools.com/media/media_mimeref.asp for more information)
$acceptabletypes = array("image/jpeg", "image/pjpeg", "image/gif", "text/plain", "text/html", "text/richtext", "video/mpeg", "video/quicktime");
//limit file size? 1 for yes, 0 no
$limitsize = 0;
//maximum file size in kb
$maxsize = 2048;
//allow overwriting? 1 for yes, 0 no
$overwriting = 1;
//do directory listing? 1 for yes, 0 no
$scandir = 1;
//make a log file? 1 for yes, 0 no
$makelog = 0;
//name of log file (must be chmod 777)
$logfile = "uploadlog.txt";
//time offset in hours (if required)
$timeoffset = +0;
//name of image details txt
$imgdetails = "imgdetails.txt";
include("uploader.php");
?>
e questa e' uploader.php
<?
function get_files($dirstr)
{
$scanfiles = array();
$fh = opendir($dirstr);
while (false!== ($filename = readdir($fh)))
{
if (is_file("$dirstr/$filename")) {
array_push($scanfiles, $filename); }
}
closedir($fh);
sort($scanfiles);
return $scanfiles;
}
$count = count($_FILES['userfile']['name']);
if ($count > 0) {
$i=0;
$f=0;
while ($i < $count) {
$kbsize = (round($_FILES['userfile']['size'][$i]/1024));
$date = date("j M Y g:ia", time()+($timeoffset*3600));
$userip = $_SERVER['REMOTE_ADDR'];
if ($limitsize == 1) {
if ($_FILES['userfile']['size'][$i] > (1024*$maxsize) ) {
$toobig[$i] = "{$_FILES['userfile']['name'][$i]} is too large! the maximum file size is $maxsize kb.";
} }
if ($acceptfilter == 1) {
if (!in_array($_FILES['userfile']['type'][$i], $acceptabletypes)) {
$rejectstring = "{$_FILES['userfile']['name'][$i]} is not of the type ";
foreach ($acceptabletypes as $acceptabletype) {
$rejectstring .= "$acceptabletype or "; }
$rejectstring = substr($rejectstring, 0, -4);
$notacceptable[$i] = "$rejectstring.";
} }
if ($overwriting!== 1) {
if(file_exists("$uploaddir/{$_FILES['userfile']['name'][$i]}")) {
$alreadyexists[$i] = "a file of the name {$_FILES['userfile']['name'][$i]} already exists! overwriting is not permitted.";
} }
if (!isset($toobig[$i]) &&!isset($notacceptable[$i]) &&!isset($alreadyexists[$i])) {
echo $uploaddir;
copy($_FILES['userfile']['tmp_name'][$i], "$uploaddir/{$_FILES['userfile']['name'][$i]}");
echo "{$_FILES['userfile']['tmp_name'][$i]} tmpname uploaded successfully!
";
echo "{$_FILES['userfile']['name'][$i]} uploaded successfully!
";
$f++;
$content .= "$date $userip uploads $uploaddir/{$_FILES['userfile']['name'][$i]} ($kbsize kb)\n";
}
elseif ($_FILES['userfile']['size'][$i]!== 0) {
echo "$toobig[$i] $notacceptable[$i] $alreadyexists[$i]
";
$content .= "$date $userip fails to upload $uploaddir/{$_FILES['userfile']['name'][$i]} ($kbsize kb) - $toobig[$i] $notacceptable[$i] $alreadyexists[$i]\n";
}
$i++;
}
echo "uploaded $f file(s)";
if ($makelog == 1) {
$handle = fopen("$logfile", "a");
fwrite ($handle, $content);
fclose ($handle); }
}
?>
<form action="<?= $_SERVER['php_SELF']."?".$_SERVER['QUERY_STRING'];?>" method="post" enctype="multipart/form-data">
Send these files:</p>
<input type="text" name="cartella" value="<? echo $_POST['url'] ?>" size="50"></p>
<?
for($d=0; $d < $fields; $d++)
{
echo "<input name=\"userfile[]\" type=\"file\" size=\"30\">";
}
?>
<input name="submit" type="submit" value="Send files" />
</p>
</form>
in effetti al primo caricamento $_POST['url'] me lo da giusto... ma quando clicco send files e la pagina ricarica se stessa... la variabile e' sparita...