| Author |
Message |
grendel FV Newbie

Joined: 08 Mar 2006 Posts: 10
 Local Time: 7:24 am
Status: Offline
|
Posted: 11/16/2006, 3:41 pm Post subject: sendAndLoad headaches |
|
|
This is in the first frame:
| AS: | var send_lv:LoadVars = new LoadVars();
var receive_lv:LoadVars = new LoadVars();
var my_lv:LoadVars = new LoadVars();
my_lv.onLoad = function(success:Boolean) {
if (success) {
send_lv.datastr = this.toString();
trace(send_lv.datastr);
send_lv.sendAndLoad("output.php", receive_lv, "POST");
receive_lv.onLoad = function(success:Boolean):Void {
if (success) {
// do what you want here
myText.text = "success";
} else {
myText.text = "failed2";
}
};
} else {
myText.text = "failed1";
}
};
my_lv.load("test.txt");
|
Testing it locally and watching it in the debugger, seeing the trace and "success" statement, it all seems to be doing what it is supposed to, yet on the server - nothing. Not even the error message. Probably not the best, nesting that second onLoad statement, but I've been pulling my hair out over this little thing and am trying anything.
This has to be simple. Any help greatly appreciated. |
|
| Back to top |
|
 |
CyanBlue FV Staff

Joined: 24 Jul 2003 Posts: 2012 Location: Chantilly, VA
 Local Time: 7:24 am
Status: Offline
|
Posted: 11/16/2006, 3:47 pm Post subject: |
|
|
Howdy and Welcome...
The script looks okay to me... A couple of questions for you...
#1. What's the full URL to the output.php and your tester HTML file that I can try???
#2. What's the output from the output.php when you execute it???
#3. You are sure your host supports the PHP, right???
#4. Your HTML, SWF and PHP files are sitting in the same directory, right??? _________________
 |
|
| Back to top |
|
 |
grendel FV Newbie

Joined: 08 Mar 2006 Posts: 10
 Local Time: 7:24 am
Status: Offline
|
Posted: 11/16/2006, 4:03 pm Post subject: |
|
|
CyanBlue!! Bless you!!
| Quote: | | #1. What's the full URL to the output.php and your tester HTML file that I can try??? |
http://www.jacobschase.com/pdf/output.php
http://www.jacobschase.com/pdf/test2.html
| Quote: | | #2. What's the output from the output.php when you execute it??? |
Sorry, I'm a php idiot. Here is the php file which processes a ascii formatted pdf and downloads a normal pdf to the client's machine:
<?php
$pdfdata = $_POST['datastr'];
// Defines the header for the page and outputs a PDF file
header("Content-type: application/pdf");
header("Content-Disposition: attachment; filename=myPDF.pdf");
header("Pragma: no-cache");
header("Expires: 0");
// $pdfdata is the variable sent from flash.
// $pdfdata contains a few non compliant characters and this fixes that
$pdfdata = str_replace(") \'", ") '", $pdfdata);
$pdfdata = str_replace("\)", ")", $pdfdata);
$pdfdata = str_replace("\(", "(", $pdfdata);
// This should be the same as CFOUTPUT
// It basically redefines the headers for the page and prints out the data in $pdfdata
// outputing a pdf file.
echo $header.'\n'.$pdfdata;
?>
| Quote: | | #3. You are sure your host supports the PHP, right??? |
Yep.
http://www.jacobschase.com/pdf/phpinfo.php
| Quote: | | #4. Your HTML, SWF and PHP files are sitting in the same directory, right??? |
Yep.
Tried it on another server as well, with the same results.
Thanks for your time. |
|
| Back to top |
|
 |
CyanBlue FV Staff

Joined: 24 Jul 2003 Posts: 2012 Location: Chantilly, VA
 Local Time: 7:24 am
Status: Offline
|
Posted: 11/16/2006, 4:49 pm Post subject: |
|
|
Hm... Interesting...
If I try to load that test.txt file, I cannot...
The simplest form of load() function does not work... Interesting... It must have to do with what's inside of the text file... Hm... |
|
| Back to top |
|
 |
grendel FV Newbie

Joined: 08 Mar 2006 Posts: 10
 Local Time: 7:24 am
Status: Offline
|
|
| Back to top |
|
 |
CyanBlue FV Staff

Joined: 24 Jul 2003 Posts: 2012 Location: Chantilly, VA
 Local Time: 7:24 am
Status: Offline
|
Posted: 11/17/2006, 9:05 am Post subject: |
|
|
Well... That won't solve much problem...
Do me a favor and post a link where I can grab the ZIP file that contains FLA, TXT and PHP files all together so that I can fiddle with it on my machine...
Oh, when you say 'testing locally', you mean that you were actually typing http://localhost/whatever.php within the IE via your IIS, correct??? |
|
| Back to top |
|
 |
grendel FV Newbie

Joined: 08 Mar 2006 Posts: 10
 Local Time: 7:24 am
Status: Offline
|
Posted: 11/17/2006, 9:29 am Post subject: |
|
|
Here is the fla, the output.php, the text file, and the html holder. There is also a index.php file that pushes that same string literal to the same php page to process it (ouput.php). I thought it was relevant since the text gets processed properly with that same output.php file, even though it's not getting sent from flash.
In regards to your question, all I was referencing was that it seemed to be working correctly when testing it from flash. I don't have php running on my local machine.
Thanks for your time. |
|
| Back to top |
|
 |
CyanBlue FV Staff

Joined: 24 Jul 2003 Posts: 2012 Location: Chantilly, VA
 Local Time: 7:24 am
Status: Offline
|
Posted: 11/17/2006, 1:11 pm Post subject: |
|
|
Um... I guess you forgot the URL...
The thing is that if you do not have PHP running in your local machine, Flash detects it as if it is a flat text file, so the outcome will be totally different... So, you probably want to point to the PHP file in the server... |
|
| Back to top |
|
 |
grendel FV Newbie

Joined: 08 Mar 2006 Posts: 10
 Local Time: 7:24 am
Status: Offline
|
|
| Back to top |
|
 |
CyanBlue FV Staff

Joined: 24 Jul 2003 Posts: 2012 Location: Chantilly, VA
 Local Time: 7:24 am
Status: Offline
|
Posted: 11/17/2006, 4:16 pm Post subject: |
|
|
Arg... Don't have F8 installed... Can you save the FLA file for FMX 2004 and upload it to the server again???  |
|
| Back to top |
|
 |
grendel FV Newbie

Joined: 08 Mar 2006 Posts: 10
 Local Time: 7:24 am
Status: Offline
|
Posted: 11/17/2006, 5:00 pm Post subject: |
|
|
Hey CyanBlue.
I think I got it figured out over here. I'll get it organized later and post what changed, but basically we did some changes in the fla and the php file, and it's working now.
thanks for your time. Hope it wasn't to much aggravation/brain damage.
Thanks again!! |
|
| Back to top |
|
 |
grendel FV Newbie

Joined: 08 Mar 2006 Posts: 10
 Local Time: 7:24 am
Status: Offline
|
Posted: 11/17/2006, 9:32 pm Post subject: |
|
|
Well after all that, here is what changed if you're still curious. In the fla, I took out the second nested loop and used "send" to pass the url of the text file:
| AS: | var send_lv:LoadVars = new LoadVars();
var my_lv:LoadVars = new LoadVars();
my_lv.onLoad = function(success:Boolean) {
if (success) {
send_lv.datastr = "test.txt";
trace(send_lv.datastr);
send_lv.send("output.php", "_self", "POST");
myText.text = "success";
} else {
myText.text = "failed";
}
};
my_lv.load("test.txt"); |
In the php file, the textfile url is passed as an argument to a "file_get_contents" command and then is sent through the pdf commands:
<?php
$txtfile = $_POST['datastr'];
//echo 'output:'.$txtfile;
$pdfdata = file_get_contents($txtfile);
// Defines the header for the page and outputs a PDF file
header("Content-type: application/pdf");
header("Content-Disposition: attachment; filename=myPDF.pdf");
header("Pragma: no-cache");
header("Expires: 0");
// $pdfdata is the variable sent from flash.
// $pdfdata contains a few non compliant characters and this fixes that
$pdfdata = str_replace(") \'", ") '", $pdfdata);
$pdfdata = str_replace("\)", ")", $pdfdata);
$pdfdata = str_replace("\(", "(", $pdfdata);
// This should be the same as CFOUTPUT
// It basically redefines the headers for the page and prints out the data in $pdfdata
// outputing a pdf file.
echo $header.'\n'.$pdfdata;
?>
Anyway, that's where it ended up and it correctly spits out a normal pdf now. Thanks again for your time and sorry about the unorganized mess this morning.  |
|
| Back to top |
|
 |
|
| View previous topic :: View next topic |