#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2004
    Location
    Marbella, Spain
    Posts
    381
    Rep Power
    0

    Save file with date+time+random number or text


    Hi,
    I want to save a file I done dynamically with FPDF and I want to save it to a folder on the server with date+time+random number or text to make sure there cant be any duplicates.
    I been searching and trying but cant manage.

    At the moment I save the file manually like this with FPDF
    PHP Code:
    $pdf->Output("bookings/filename55.pdf","F");
    $path "bookings/filename55.pdf"
    And I send it with phpmailer like this:
    PHP Code:
    $asunto "$row->propiedad$row->llegada - $row->salida";
    $mail->AddAttachment($path$asunto$encoding 'base64'$type 'application/pdf');
    if(!
    $mail->Send())
    {
    echo 
    "Message could not be sent, enter a valid e-mail. <p>";
    echo 
    "Mailer Error: " $mail->ErrorInfo;
    exit;

    Comments on this post

    • ptr2void disagrees : 381 posts, too selfish and inconsiderate to use code tags? -381 reputation.
    Last edited by helenp; January 2nd, 2013 at 08:27 AM.
  2. #2
  3. Sarcky
    Devshed Supreme Being (6500+ posts)

    Join Date
    Oct 2006
    Location
    Pennsylvania, USA
    Posts
    10,908
    Rep Power
    6352
    PHP has a uniqid() function.

    Also, read the new user guide and format your code properly.
    HEY! YOU! Read the New User Guide and Forum Rules

    "They that can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety." -Benjamin Franklin

    "The greatest tragedy of this changing society is that people who never knew what it was like before will simply assume that this is the way things are supposed to be." -2600 Magazine, Fall 2002

    Think we're being rude? Maybe you asked a bad question or you're a Help Vampire. Trying to argue intelligently? Please read this.
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2004
    Location
    Marbella, Spain
    Posts
    381
    Rep Power
    0
    Originally Posted by ManiacDan
    PHP has a uniqid() function.

    Also, read the new user guide and format your code properly.
    Sorry did not put tags as code was so short, thought better and easier to view without.

    Thanks will check for uniqid, but I would like the date also, as well to know the date of the booking.

    Btw, what happened with my reputacion? It went to cero.
    I am not selfish, only that I hardly ever cant help as I am not a gury, and it takes me a long time to found out how to do things as I have autolearnt at an older age, and I am so superbusy redoing my huge site that are dying due to the crisis.
    I always help when I can.
    Last edited by helenp; January 2nd, 2013 at 09:58 AM.
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2004
    Location
    Marbella, Spain
    Posts
    381
    Rep Power
    0
    solved it, thanks for the uniqueid()

    PHP Code:
    $fechadate('Y-m-d:h-i-s'time());echo "$fecha";
    $fileuniqid(); 
    $pdf->Output("bookings/".$fecha.$file."booking.pdf","F");
    $path "bookings/".$fecha.$file."booking.pdf"
    Last edited by helenp; January 2nd, 2013 at 09:59 AM.

IMN logo majestic logo threadwatch logo seochat tools logo