Hi,
I have this code which is a simple upload script. I have added in a field which when submitted should upload a 'description' of the file.
The problem Im having is when I submit the form, all of the descriptions suddenly change to the descriotion i have just typed in, then suddenly change back to the default "NA". I cant get the descriptions to upload and remain as I want them to be.
This is my code:
<?php
error_reporting(0);
$destination="test";
echo 'My Table headers go here ie Filename, Filesize blah blah;
$directory = opendir($destination);
while( $file = readdir( $directory ) )
{
$file_ar[] = $file;
}
foreach( $file_ar as $file )
{
if( $file == ".." || $file == "." )
{
continue;
}
$type= strrchr($file,'.');
$name=$file;
$name2=$destination."/".$file;
if($type==''){$type='dir';}
$sizeoff=filesize($name2);
$time=date("D M j Y",filectime($name2));
if($time=='Wed Dec 31 1969'){$time='Unknown';}
if($sizeoff==''){$sizeoff='Unknown';}
if($sizeoff=='0'){$sizeoff='Unknown';}
$file2 = dirname($name2);
// This is where I think Im Going wrong..................................
if (empty($description) || !isset($description)) {
$description = "NA";
}
// The Line above - Am I Missing something?..............................
if($color == "FFFFFF") {
$color = "FFFFFF";
} else {
$color = "FFFFFF";
}
echo"<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0><TR><TD ALIGN=center WIDTH=250 bgcolor='$color'><a href='test/$uname$file' target=_blank>$name</a></font></TD><TD ALIGN=center WIDTH=250 bgcolor='$color'>$sizeoff</TD><TD ALIGN=center WIDTH=250 bgcolor='$color'>$type</TD><TD ALIGN=center WIDTH=250 bgcolor='$color'>$time</TD><TD ALIGN=center WIDTH=100 bgcolor='$color'>$description</TD></TABLE>";
}
echo "<CENTER><FONT SIZE='+2' COLOR=\"6699CC\"><BR>Upload Your File</FONT><BR><BR><FORM ACTION='$PHP_SELF' METHOD=post enctype=\"multipart/form-data\"><INPUT TYPE='file' size='20' name='filename'></CENTRE><BR><CENTER> <input type=\"hidden\" name=\"action\" value=\"uploadProg\"><INPUT TYPE='hidden' name='action' value='upload'><br><br>Description<input type='text' name='description'><br><br><INPUT TYPE='submit' value='Upload File'></CENTER></FORM>";
closedir($directory);
if($action==''){$action='noaction';}else{$action=$action;}
if($action=='upload')
{
$filename==$filename_name;
$action=('uploadprog');
$destination="test";
copy($filename,$destination."/".$filename_name);
echo "<h2>File Uploaded.</h2>";
echo "<HEAD><META HTTP-EQUIV='Refresh' CONTENT=1></HEAD>";
}
if ($filename=="none") {echo("<h1>No File Selected....</h1>"); break;}
uploadProg($filename,$filename_name);
break;
?>
Any Ideas please?