Hello,
I have the following code:
[PHP]
$RecordID = $_POST['PKid'];
$LastModBy= $_POST['LastModBy'];
// These datetime vars live in globals.php
$mySQLToday = $thisYear.'-'.$thisMonth.'-'.$thisDay; // prints todays date in YYYY-MM-DD format
$attachment_type = "workAttachs"; // What is the file type for this section?
$file_path = $datastore_root."/".$owner."/".$attachment_type."/".$thisYear."/".$thisMonth."/".$thisDay;
$link_path = "/".$attachment_type."/".$thisYear."/".$thisMonth."/".$thisDay."/";
function mkPath($path) {
$dirs=array();
$path=preg_replace('/(\/){2,}|(\\\){1,}/','/',$path); //only forward-slash
$dirs=explode("/",$path);
$path="";
foreach ($dirs as $element) {
$path.=$element."/";
if(!is_dir($path)) {if(!mkdir($path)){ return '/tmp';}
}
}
return $path;
}
$upld_dir = mkPath($file_path);
if ((isset($_POST["MMUpload"])) && ($_POST["MMUpload"] == "formUpload")) {
$insertSQL = sprintf("INSERT INTO files (file, content) VALUES (%s, %s)",
GetSQLValueString($_POST['UpldFile'], "text"),
GetSQLValueString($_POST['FKcontent'], "text"));
mysql_select_db($db_common, $common);
$Result1 = mysql_query($insertSQL, $common) or die(mysql_error());
}
if ($_REQUEST['uploadDir']) {
$output_file = array_slice($_FILES['Filedata'], 0, 1);
foreach ($output_file as $files) {
$uploadFile = $upld_dir . $_FILES['Filedata']['name'];
if(move_uploaded_file($_FILES['Filedata']['tmp_name'], $uploadFile)){
echo '<body onLoad="document.formUpload.submit()">
<form name="form_upload" action='.$_SERVER['PHP_SELF'].'>
<input type="hidden" name="MMUpload" value="formUpload">
<input type="hidden" name="UpldFile" value='.$upld_dir . $files.'>
<input type="hidden" name="LastModBy" value='.$_POST['LastModBy'].'>
<input type="hidden" name="FKcontent" value='.$RecordID.'>
</form>
</body>';
$result = '<body onLoad="document.formUpload.submit()">
<form name="form_upload" action='.$_SERVER['PHP_SELF'].'>
<input type="hidden" name="MMUpload" value="formUpload">
<input type="hidden" name="UpldFile" value='.$upld_dir . $files.'>
<input type="hidden" name="LastModBy" value='.$LastModBy.'>
<input type="hidden" name="FKcontent" value='.$RecordID.'>
</form>
</body>';
}
$filename = 'test.txt';
// Let's make sure the file exists and is writable first.
if (is_writable($filename)) {
// In our example we're opening $filename in append mode.
// The file pointer is at the bottom of the file hence
// that's where $somecontent will go when we fwrite() it.
if (!$handle = fopen($filename, 'a')) {
echo "Cannot open file ($filename)";
exit;
}
// Write $somecontent to our opened file.
if (fwrite($handle, $result) === FALSE) {
echo "Cannot write to file ($filename)";
exit;
}
echo "Success, wrote ($result) to file ($filename)";
fclose($handle);
} else {
echo "The file $filename is not writable";
}
}
}
if ($_REQUEST['action'] == 'getMaxFilesize') {
echo "&maxFilesize=".ini_get('upload_max_filesize') ;
}
?>[/PHP]
My problem is that the two top POST variable values are not posting in the output form section (in bold and italics), though the POST variable values are echoing fine so I know they are being posted from the previous page...Thanx for any help...