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_typ e = "workAttach s"; // What is the file type for this section?
$file_path = $datastore_root ."/".$owner."/".$attachment_t ype."/".$thisYear ."/".$thisMont h."/".$thisDay;
$link_path = "/".$attachment_t ype."/".$thisYear ."/".$thisMont h."/".$thisDay. "/";
function mkPath($path) {
$dirs=array();
$path=preg_repl ace('/(\/){2,}|(\\\){1,}/','/',$path); //only forward-slash
$dirs=explode("/",$path);
$path="";
foreach ($dirs as $element) {
$path.=$element ."/";
if(!is_dir($pat h)) {if(!mkdir($pat h)){ return '/tmp';}
}
}
return $path;
}
$upld_dir = mkPath($file_pa th);
if ((isset($_POST["MMUpload"])) && ($_POST["MMUpload"] == "formUpload ")) {
$insertSQL = sprintf("INSERT INTO files (file, content) VALUES (%s, %s)",
GetSQLValueStri ng($_POST['UpldFile'], "text"),
GetSQLValueStri ng($_POST['FKcontent'], "text"));
mysql_select_db ($db_common, $common);
$Result1 = mysql_query($in sertSQL, $common) or die(mysql_error ());
}
if ($_REQUEST['uploadDir']) {
$output_file = array_slice($_F ILES['Filedata'], 0, 1);
foreach ($output_file as $files) {
$uploadFile = $upld_dir . $_FILES['Filedata']['name'];
if(move_uploade d_file($_FILES['Filedata']['tmp_name'], $uploadFile)){
echo '<body onLoad="documen t.formUpload.su bmit()">
<form name="form_uplo ad" action='.$_SERV ER['PHP_SELF'].'>
<input type="hidden" name="MMUpload" value="formUplo ad">
<input type="hidden" name="UpldFile" value='.$upld_d ir . $files.'>
<input type="hidden" name="LastModBy " value='.$_POST['LastModBy'].'>
<input type="hidden" name="FKcontent " value='.$Record ID.'>
</form>
</body>';
$result = '<body onLoad="documen t.formUpload.su bmit()">
<form name="form_uplo ad" action='.$_SERV ER['PHP_SELF'].'>
<input type="hidden" name="MMUpload" value="formUplo ad">
<input type="hidden" name="UpldFile" value='.$upld_d ir . $files.'>
<input type="hidden" name="LastModBy " value='.$LastMo dBy.'>
<input type="hidden" name="FKcontent " value='.$Record ID.'>
</form>
</body>';
}
$filename = 'test.txt';
// Let's make sure the file exists and is writable first.
if (is_writable($f ilename)) {
// 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('uploa d_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...
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_typ e = "workAttach s"; // What is the file type for this section?
$file_path = $datastore_root ."/".$owner."/".$attachment_t ype."/".$thisYear ."/".$thisMont h."/".$thisDay;
$link_path = "/".$attachment_t ype."/".$thisYear ."/".$thisMont h."/".$thisDay. "/";
function mkPath($path) {
$dirs=array();
$path=preg_repl ace('/(\/){2,}|(\\\){1,}/','/',$path); //only forward-slash
$dirs=explode("/",$path);
$path="";
foreach ($dirs as $element) {
$path.=$element ."/";
if(!is_dir($pat h)) {if(!mkdir($pat h)){ return '/tmp';}
}
}
return $path;
}
$upld_dir = mkPath($file_pa th);
if ((isset($_POST["MMUpload"])) && ($_POST["MMUpload"] == "formUpload ")) {
$insertSQL = sprintf("INSERT INTO files (file, content) VALUES (%s, %s)",
GetSQLValueStri ng($_POST['UpldFile'], "text"),
GetSQLValueStri ng($_POST['FKcontent'], "text"));
mysql_select_db ($db_common, $common);
$Result1 = mysql_query($in sertSQL, $common) or die(mysql_error ());
}
if ($_REQUEST['uploadDir']) {
$output_file = array_slice($_F ILES['Filedata'], 0, 1);
foreach ($output_file as $files) {
$uploadFile = $upld_dir . $_FILES['Filedata']['name'];
if(move_uploade d_file($_FILES['Filedata']['tmp_name'], $uploadFile)){
echo '<body onLoad="documen t.formUpload.su bmit()">
<form name="form_uplo ad" action='.$_SERV ER['PHP_SELF'].'>
<input type="hidden" name="MMUpload" value="formUplo ad">
<input type="hidden" name="UpldFile" value='.$upld_d ir . $files.'>
<input type="hidden" name="LastModBy " value='.$_POST['LastModBy'].'>
<input type="hidden" name="FKcontent " value='.$Record ID.'>
</form>
</body>';
$result = '<body onLoad="documen t.formUpload.su bmit()">
<form name="form_uplo ad" action='.$_SERV ER['PHP_SELF'].'>
<input type="hidden" name="MMUpload" value="formUplo ad">
<input type="hidden" name="UpldFile" value='.$upld_d ir . $files.'>
<input type="hidden" name="LastModBy " value='.$LastMo dBy.'>
<input type="hidden" name="FKcontent " value='.$Record ID.'>
</form>
</body>';
}
$filename = 'test.txt';
// Let's make sure the file exists and is writable first.
if (is_writable($f ilename)) {
// 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('uploa d_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...
Comment