Page 1 of 1

Stuck on php download code

Posted: Sat Apr 12, 2014 9:26 am
by Shirley123
Hi

I am new at this took me ages to get where I am, but I done a simple routeplanner with Googlemaps API and I am trying to get it to download the route a person plans in .gpx.

Can anyone see what I an doing wrong?

In the main html document the part to tell it to go to the download.php is:-

Code: Select all

  <form id="formExportData" method="post" action="Download.php" enctype="multipart/form-data" style="display:none">
    <textArea id="exportData" name="exportData"></textArea>
   </form>
 
  <input name="file" id="file" type="file" style="display:none" />


The download.php file says:-

Code: Select all

<? ob_start(); ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR...ransitional.dtd">
 <html xmlns="http://www.w3.org/1999/xhtml">
 <head>
 <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
 <title>Untitled Document</title>
 </head>
 
<body><?php
 
//download.php
 //content type header('Content-type: Application/octet-stream');
 //open/save dialog box
 header('Content-Disposition: attachment; filename="MyRoute.gpx"');
 //read from server and write to buffer
 readfile('(i put the full path of page)/text.txt');
 
?>
 </body>
 </html><? ob_flush(); ?>


the text.txt is readable and writeable.


But when I just look at the MyRoute.gpx in notepad to see whats in it, is is blank all it says is:-

Code: Select all

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR...ransitional.dtd">
 <html xmlns="http://www.w3.org/1999/xhtml">
 <head>
 <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
 <title>Untitled Document</title>
 </head>
 
<body></body>
 </html>

What am i missing or doing wrong in the code ??

How can I get the route to save??

thanks

Shirl

Re: Stuck on php download code

Posted: Sun Apr 13, 2014 11:42 pm
by requinix
Are you absolutely sure you have the correct path? And that the file has contents? If you don't already, put

Code: Select all

error_reporting = -1
display_errors = on
in your php.ini, restart your server, and see if your script outputs any errors.

While I'm here, you know you're not outputting valid GPX yet, right?

Re: Stuck on php download code

Posted: Mon Apr 14, 2014 6:36 pm
by Shirley123
How do I find the file that the googlemaps writes the details of the route to?

All I done is call the file text.txt but I dont know for sure it is that.

Where do I find where it copies to formExportData.

I just picked up codes from looking at the internet I am new at this really, all seems ok except the saving route part. I know I am missing something or not finding where the route is writing to.

thx
shirl

Re: Stuck on php download code

Posted: Mon Apr 14, 2014 8:40 pm
by requinix
Shirley123 wrote:How do I find the file that the googlemaps writes the details of the route to?
That question doesn't make sense. Google Maps doesn't write stuff to a file.
Shirley123 wrote:All I done is call the file text.txt but I dont know for sure it is that.
Well then you should check that, huh?
Shirley123 wrote:Where do I find where it copies to formExportData.
Again, doesn't make sense, stuff isn't getting copied to a form.
Shirley123 wrote:I just picked up codes from looking at the internet I am new at this really, all seems ok except the saving route part. I know I am missing something or not finding where the route is writing to.
You can't just "pick up codes" to make stuff work. Software isn't a set of cheats for a videogame. Software is a child that you have to take responsibility for, to look after, and to clean up after.