Page 1 of 2 12 LastLast
Results 1 to 10 of 12

Thread: redirecting the form after download

  1. #1
    Join Date
    Feb 2010
    Posts
    21
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default redirecting the form after download

    Hello Guys,

    i am using php code to file download i want to redirect that page after the download is done or i need to redirect to the next page and download option should appear what should i so for this. really my head got too hot to solve this please suggest me solution as soon as possible .

  2. #2
    Join Date
    Mar 2007
    Location
    New York, NY
    Posts
    557
    Thanks
    8
    Thanked 66 Times in 66 Posts

    Default

    Please post a link to the page on your site that contains the problematic script so we can check it out.
    - Josh

  3. #3
    Join Date
    Feb 2010
    Posts
    21
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Lightbulb

    Thanks for reply,

    i think its not clear for you what i need , i can`t send my url but i will explain you with a small example here.

    PHP Code:
                                 <?php

    $name 
    "test.pdf";

    $fp =fopen($name'rb');

    // send headers, dump the pdf file and finally redirect
    header("Content-Type: application/pdf");
    header("Content-Disposition: attachment; filename=$name");
    header("Content-Length: " filesize($name));
    fpassthru($fp);

    readfile($fp); 
    header("refresh: 2; url=test1.html");


    ?>
    after download i need to redirect to another page for that i used some thing like this it worked fine in FF but not working in IE . Can you check this and provide me some solution.
    Last edited by jscheuer1; 09-17-2011 at 02:22 PM. Reason: formatting

  4. #4
    Join Date
    Apr 2008
    Location
    So.Cal
    Posts
    3,643
    Thanks
    63
    Thanked 516 Times in 502 Posts
    Blog Entries
    5

    Default

    you can't send more headers (your redirect) after you send regular data (your PDF). Your best best would be to have the download open in a new window, and redirect the original window (e.g., the [download] button would open the PDF in a new window, and you could use javascript to detect the click and ask the server for the redirect page).

  5. #5
    Join Date
    Feb 2010
    Posts
    21
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Post

    Hello thanks for the reply.

    I am not much clear how to do this , can you give me some example with explanation.

  6. #6
    Join Date
    Apr 2008
    Location
    So.Cal
    Posts
    3,643
    Thanks
    63
    Thanked 516 Times in 502 Posts
    Blog Entries
    5

    Default

    basically, you can't do this in a single page. once you send output to the browser (yuor pdf file), you can't send more headers (your redirect). so, a possible solution is to do it on two different pages.

    If you post your code I might be able to give you an example.

  7. #7
    Join Date
    Feb 2010
    Posts
    21
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default

    Ya, my code is already posted here please go through my second post and give me some solution for that.

  8. #8
    Join Date
    Apr 2008
    Location
    So.Cal
    Posts
    3,643
    Thanks
    63
    Thanked 516 Times in 502 Posts
    Blog Entries
    5

    Default

    you only posted a section of php code, which you said was only "an example." please post your actual php code, and the html markup of the referring page as well, so we can determine what the best approach would be.

  9. #9
    Join Date
    Feb 2010
    Posts
    21
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Post

    okay,

    this is my first page after all the form fields are submitted i am creating a pdf using tcpdf

    and at the end i am redirecting to the next page as you see below its redirecting in mozilla and its not working in ie .. i think this may give you the clear idea ..

    PHP Code:
    require_once('config/lang/eng.php');
    require_once(
    'tcpdf.php');

    // Extend the TCPDF class to create custom Header and Footer
    class MYPDF extends TCPDF {





        
    //Page header
        
    public function Header() {
            
    // Logo
            //$image_file = K_PATH_IMAGES.'logo.jpg';
            //$this->Image($image_file, 10, 10, 60, '', 'JPG', '', 'T', false, 300, '', false, false, 0, false, false, false);

            // Set font
            
    $this->SetFont('helvetica''B'25);
            
    // Title
            
    $this->Cell(00'Trip Invoice'0false'R'0''0false'T''M');

        }

        
    // Page footer
        
    public function Footer() {
            
    // Position at 15 mm from bottom
            
    $this->SetY(-15);
            
    // Set font
            
    $this->SetFont('helvetica''I'8);
            
    // Page number
            //$this->Cell(0, 10, 'Page '.$this->getAliasNumPage().'/'.$this->getAliasNbPages(), 0, false, 'C', 0, '', 0, false, 'T', 'M');
        
    }
    }


    // create new PDF document
    $pdf = new MYPDF(PDF_PAGE_ORIENTATIONPDF_UNITPDF_PAGE_FORMATtrue'UTF-8'false);

    // set document information
    $pdf->SetCreator(PDF_CREATOR);
    $pdf->SetAuthor('MY Red Cap');
    $pdf->SetTitle('My Trip Invoice');
    $pdf->SetSubject('My Trip Invoice');
    $pdf->SetKeywords(', PDF, Invoice, trip, guide');

    // set default header data
    $pdf->SetHeaderData(PDF_HEADER_LOGOPDF_HEADER_LOGO_WIDTHPDF_HEADER_TITLEPDF_HEADER_STRING);

    // set header and footer fonts
    $pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN''PDF_FONT_SIZE_MAIN));
    $pdf->setFooterFont(Array(PDF_FONT_NAME_DATA''PDF_FONT_SIZE_DATA));

    // set default monospaced font
    $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);

    //set margins
    $pdf->SetMargins(PDF_MARGIN_LEFTPDF_MARGIN_TOPPDF_MARGIN_RIGHT);
    $pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
    $pdf->SetFooterMargin(PDF_MARGIN_FOOTER);

    //set auto page breaks
    $pdf->SetAutoPageBreak(TRUEPDF_MARGIN_BOTTOM);

    //set image scale factor
    $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);

    //set some language-dependent strings
    $pdf->setLanguageArray($l);

    // ---------------------------------------------------------

    // set font
    $pdf->SetFont(''''10);

    // add a page
    $pdf->AddPage();
     echo 
    $date=date("m/d/y");
    require(
    'htmlcolors.php');

    // set some text to print



    $html = <<<EOD

    <table border="1" cellspacing="0" cellpadding="4" bottom="5">
        <tr >
            <td>
    $fullname<br />$address,$city <br /> $state<br />$zip<br />$phone</td><td align="right"> Invoice # $id<br />
                                           DATE: 
    $date</td>
        </tr>
        <tr>
            <td width="35">TO</td><td width="604"></td>

        </tr>

    </table>
    <br/>

    <br/>

    EOD;
    // output the HTML content
     
    $pdf->writeHTML($htmltruefalsetruefalse'');

    // Print some HTML Cells



    $pdf->SetFillColor(255,255,0);




    // print a block of text using Write()
    //$pdf->WriteHTML($html,$h=0,$txt, $link='', $fill=0, $align='L', $ln=true, $stretch=0, $firstline=false, $firstblock=false, $maxh=0);

    // ---------------------------------------------------------
    $filename=invoice_;
      
    $file_name="$filename"rand().".pdf";

    //Close and output PDF document

    ob_clean();

    $pdf->Output('tripinvoice/'.$file_name'D');
    $pdf->Output('tripinvoice/'.$file_name'F');

    // Exit script. So that no useless data is output-ed.


    //============================================================+
    // END OF FILE
    //============================================================+

    //-----------------------------END Code For PDF Generation--------------------\\
      
    header("refresh: 3; URL=mytripinvoice.php?type="$_GET['type']); 
    Last edited by jscheuer1; 09-17-2011 at 02:23 PM. Reason: formatting

  10. #10
    Join Date
    Feb 2010
    Posts
    21
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default

    Hello guys ,

    I have solved this problem.using iframe , i have taken my complete download code to the new page and i am using iframe to call that download code page where ever it is needed . That`s it solves my problem.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •