Solved

parsing $HTTP_RAW_POST_DATA????

Posted on 2004-04-18
3
865 Views
Last Modified: 2012-06-22
Ok this may be really basic for you gurus.  
I have my form script working well, Thanks!!!
I would like to parse the pot data and use it to name the temp file.
Heres the peice of script Im useing:
$tmpfname = tempnam("/tmp", "tmp_");
$tmpfname .= ".fdf";
$fptr = fopen("$tmpfname", "w");
fputs($fptr, $HTTP_RAW_POST_DATA);
fclose($fptr);

This is the Data that gets sent from Acrobat:
%FDF-1.2
%âãÏÓ
1 0 obj<</FDF<</F(/E/Sites/worldtraveldoctor/test.pdf)/ID[<3052e91251426183a1255e1805a2501f><d114c6a103ad2c439a6efc0fb5bc3912>]/Fields[<</T(lastname)/V(Smith)>><</T(firstname)/V(Bill)>>]>>>>
endobj
trailer
<</Root 1 0 R>>
%%EOF


I would like to take lastname field and the firstname field and add it as the prefix of the temp file name.  
so instead of
$tmpfname = tempnam("/tmp", "tmp_");

It should be
$tmpfname = tempnam("/tmp", "$lastname_$firstname_");  //or something like that

So the file name would be Smith_Bill_uniquefilename.fdf
0
Comment
Question by:livegirllove
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 12

Accepted Solution

by:
venkateshwarr earned 500 total points
ID: 10855105
If you have FDF Toolkit installed.. then you can do this easily...

For example

<?php

   $fdffp = fopen("test.fdf", "w");
   fwrite($fdffp, $HTTP_RAW_POST_DATA, strlen($HTTP_RAW_POST_DATA));
   fclose($fdffp);

   $fdf = fdf_open("test.fdf");
   $firstname = fdf_get_value($fdf, "firstname");
   echo "firstname = $firstname \n";

   $lastname = fdf_get_value($fdf, "lastname");
   echo "lastname = $lastname \n";
   fdf_close($fdf);

 // $tmpfname = tempnam("/tmp", "tmp_");
  $filename = "$lastname_$firstname_test.fdf"
   $fdffp = fopen($filename, "w");
   fwrite($fdffp, $HTTP_RAW_POST_DATA, strlen($HTTP_RAW_POST_DATA));
   fclose($fdffp);
    // OR you can simple rename test.fdf to $lastname_$firstname_test.fdf
?>


Check this link for more details..
http://www.phpbuilder.com/columns/uwe20001116.php3?aid=154&print_mode=1
0
 
LVL 12

Expert Comment

by:venkateshwarr
ID: 10855108

FDF toolkit can be downloaded from
http://partners.adobe.com/asn/acrobat/forms.jsp
0
 
LVL 1

Author Comment

by:livegirllove
ID: 10855515
thanks, I was trying to avoid installing the tool kit, but Ill look into it then get back to this post.
0

Featured Post

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
Many old projects have bad code, but the budget doesn't exist to rewrite the codebase. You can update this code to be safer by introducing contemporary input validation, sanitation, and safer database queries.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to count occurrences of each item in an array.

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question