Solved

parsing $HTTP_RAW_POST_DATA????

Posted on 2004-04-18
3
852 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
  • 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Consider the following scenario: You are working on a website and make something great - something that lets the server work with information submitted by your users. This could be anything, from a simple guestbook to a e-Money solution. But what…
Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

760 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now