code works on server A, but not server B, need help
Posted: Mon May 02, 2011 5:43 pm
Hi
I have a web page that upon submission creates a link to click on, which is a FDF file (data file for a PDF file), when clicked, places the contents of the fdf file into the pdf file.
to see this working go to
http://inovacapitalmanagement.com/adpf
but at this site:
http://www.americanlaw1.com/apdf
instead of, after clicking on the result link the pdf file, i get the text of the fdf file instead, which naturally drives me crazy, because i dont understand how the same code will work on one server but not the next:
The permissions for the 'results' folder at site 1 is 755. but if i try 755 at site 2 it wont allow the creation of the fdf file. but if i change the permissions of the results folder at site 2 to 777 the fdf file will get created, but then when i click on the results link all i get is the text of the fdf file.
I have a web page that upon submission creates a link to click on, which is a FDF file (data file for a PDF file), when clicked, places the contents of the fdf file into the pdf file.
to see this working go to
http://inovacapitalmanagement.com/adpf
Code: Select all
<?php
require_once 'createFDF.php';
$pdf_file='http://www.inovacapitalmanagement.com/apdf/v12.pdf';
// allow for up to 25 different files to be created, based on the minute
$min=date('i') % 25;
$fdf_file=dirname(__FILE__).'/results/posted-'.$min.'.fdf';
if(isset($_POST['b_fname'])){
$_POST['b_cphone']=$_POST['b_cphone'];
// get the FDF file contents
$fdf=createFDF($pdf_file,$_POST);
// Create a file for later use
if($fp=fopen($fdf_file,'w')){
fwrite($fp,$fdf,strlen($fdf));
$CREATED=TRUE;
}else{
echo 'Unable to create file: '.$fdf_file.'<br><br>';
$CREATED=FALSE;
}
fclose($fp);
}
?>
Code: Select all
<?php
function createFDF($file,$info){
$data="%FDF-1.2\n%âãÏÓ\n1 0 obj\n<< \n/FDF << /Fields [ ";
foreach($info as $field => $val){
if(is_array($val)){
$data.='<</T('.$field.')/V[';
foreach($val as $opt)
$data.='('.trim($opt).')';
$data.=']>>';
}else{
$data.='<</T('.$field.')/V('.trim($val).')>>';
}
}
$data.="] \n/F (".$file.") /ID [ <".md5(time()).">\n] >>".
" \n>> \nendobj\ntrailer\n".
"<<\n/Root 1 0 R \n\n>>\n%%EOF\n";
return $data;
}
?>but at this site:
http://www.americanlaw1.com/apdf
instead of, after clicking on the result link the pdf file, i get the text of the fdf file instead, which naturally drives me crazy, because i dont understand how the same code will work on one server but not the next:
Code: Select all
<?php
require_once 'createFDF.php';
$pdf_file='http://www.americanlaw1.com/apdf/v12.pdf';
// allow for up to 25 different files to be created, based on the minute
$min=date('i') % 25;
$fdf_file=dirname(__FILE__).'/results/posted-'.$min.'.fdf';
if(isset($_POST['b_fname'])){
$_POST['b_cphone']=$_POST['b_cphone'];
// get the FDF file contents
$fdf=createFDF($pdf_file,$_POST);
// Create a file for later use
if($fp=fopen($fdf_file,'w')){
fwrite($fp,$fdf,strlen($fdf));
$CREATED=TRUE;
}else{
echo 'Unable to create file: '.$fdf_file.'<br><br>';
$CREATED=FALSE;
}
fclose($fp);
}
?>
The permissions for the 'results' folder at site 1 is 755. but if i try 755 at site 2 it wont allow the creation of the fdf file. but if i change the permissions of the results folder at site 2 to 777 the fdf file will get created, but then when i click on the results link all i get is the text of the fdf file.