buid filename with concatenation

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Tinus
    New Member
    • Jul 2010
    • 30

    #1

    buid filename with concatenation

    Hi

    I need to click on a button that will download a file.
    The problem is how I will indicate a filename.

    Files are stored in folders tcp20100220,tcp 20100220.
    It depends on a date given by the user.The file in the folder will be named in the same way but will be a pdf file.(tcp201002 20.pdf)

    1 .A form is given to the user where he/she enters a date.Then a file is generated in the specific folder.
    2. A new html page opens with a download button.

    My problem:
    Button is html.

    The date is received into php as follow

    Code:
    $indate=$_POST["inputdate"];
    echo " indate is".$indate;  
    //ghet input date
    if (isset($_POST["inputdate"])){ 
    $MyToday=date("Ymd");
    $MyToday=strtotime($indate);}
    else{
    $MyToday=$today;}
    echo"...";
    now the download button cannot be created in php so I need to use Html.

    Something like the following should be done

    Code:
    <html> 
    <title>HTML with PHP</title>
    <body>
    
    <input type="button" value="Download Result" onClick="window.location.href='http://111.111.11.117/besa/SASoutput/tcp"<?php date('Ymd',$MyToday) ?>>/tcp"<?php date('Ymd',$MyToday) ?>>.pdf">
    </html>
    Please give me some direction as you can see I have no idea how to go ahead.
    Last edited by Niheel; Sep 29 '10, 08:52 AM.
  • johny10151981
    Top Contributor
    • Jan 2010
    • 1059

    #2
    if you had search before posting you would get result both on google and in this forum
    follow the link

    Comment

    • Tinus
      New Member
      • Jul 2010
      • 30

      #3
      Thank you.
      So if I have a file in C:\aptana\xampp-win32-1.7.3\xampp\htd ocs\besa\RD_Env _ICV5\Report\Mt M_Bond_20100826
      named TRI_FP20100826. pdf

      Why is the following giving me the message "file missing in the server"

      Code:
      $thedate="20100826"
      if
       (file_exists("C:/aptana/xampp-win32-1.7.3/xampp/htdocs/besa/RD_Env_ICV5/Report/MtM_Bond_".$thedate."/"."TRI_FP".$thedate."pdf")==false) 
       { 
        echo "<message>file missing in the server</message>";  
        exit; 
       }
      I know this might be another stupid question but I have a deadline and this neads to be finished in time.

      Comment

      • johny10151981
        Top Contributor
        • Jan 2010
        • 1059

        #4
        Code:
        file_exists("C:/aptana/xampp-win32-1.7.3/xampp/htdocs/besa/RD_Env_ICV5/Report/MtM_Bond_".$thedate."/"."TRI_FP".$thedate."pdf"
        this has a bug. the bug is there is "." before pdf

        last 4 bytes of the file name is ".pdf" but you are checking for "6pdf"

        Comment

        Working...