January 2nd, 2013, 07:30 AM
Save file with date+time+random number or text
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
And I send it with phpmailer like this:
$path = "bookings/filename55.pdf";
$asunto = "$row->propiedad, $row->llegada - $row->salida";
$mail->AddAttachment($path, $asunto, $encoding = 'base64', $type = 'application/pdf');
echo "Message could not be sent, enter a valid e-mail. <p>";
echo "Mailer Error: " . $mail->ErrorInfo;
Comments on this post
Last edited by helenp; January 2nd, 2013 at 08:27 AM.
January 2nd, 2013, 08:21 AM
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.
January 2nd, 2013, 08:26 AM
Sorry did not put tags as code was so short, thought better and easier to view without.
Originally Posted by ManiacDan
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.
January 2nd, 2013, 09:20 AM
solved it, thanks for the uniqueid()
$fecha= date('Y-m-d:h-i-s', time());echo "$fecha";
$path = "bookings/".$fecha.$file."booking.pdf";
Last edited by helenp; January 2nd, 2013 at 09:59 AM.