Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 112851
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T02:36:35+00:00 2026-05-11T02:36:35+00:00

I need to convert some files to PDF and then attach them to an

  • 0

I need to convert some files to PDF and then attach them to an email. I’m using Pear Mail for the email side of it and that’s fine (mostly–still working out some issues) but as part of this I need to create temporary files. Now I could use the tempnam() function but it sounds like it creates a file on the filesystem, which isn’t what I want.

I just want a name in the temporary file system (using sys_get_temp_dir()) that won’t clash with someone else running the same script of the same user invoking the script more than once.

Suggestions?

  • 1 1 Answer
  • 1 View
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T02:36:36+00:00Added an answer on May 11, 2026 at 2:36 am

    I’ve used uniqid() in the past to generate a unique filename, but not actually create the file.

    $filename = uniqid(rand(), true) . '.pdf'; 

    The first parameter can be anything you want, but I used rand() here to make it even a bit more random. Using a set prefix, you could further avoid collisions with other temp files in the system.

    $filename = uniqid('MyApp', true) . '.pdf'; 

    From there, you just create the file. If all else fails, put it in a while loop and keep generating it until you get one that works.

    while (true) {  $filename = uniqid('MyApp', true) . '.pdf';  if (!file_exists(sys_get_temp_dir() . $filename)) break; } 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some .class files that I need to convert to .java so I
I need to convert PDF files into .doc files using C#. The computer has
I'm starting to develop applications using C++11 lambdas, and need to convert some types
I need to convert PDF pages to TIF files from within my app (or
In my application, I need to convert PDF docs to PCL5 generic files to
I receive some xml-files with embedded base64-encoded images, that I need to decode and
I have an interesting question today. I need to convert some pokemon audio files
I've got some local files that need to be updated from S3 occasionally. I'd
I need to convert relative image path (inside some css files) to absolute on
I need to convert some strings, and pull out the two first integers e.g:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.