/    Sign up×
Community /Pin to ProfileBookmark

Creating a temporary file and the url

Hello,
I’m sorry, my English is bad

This code works fine.

But, I want to create a temporary pdf file and the url

Example:
//echo base64_decode($content);
$my_pdf_files = base64_decode($content);
[url]www.mysite.com/4534546246246.pdf[/url]
like,
Can you help?

pdf.php

[code=php]
<?php
$pdffile_date=$row[‘pdf_file_name’];
$pdffiledate = substr($pdffile_date,0,21);
$file = “./pdfs/”.$row[‘pdf_file_name’];
$transaction = fopen($file, “r”);
$content = fread($transaction, filesize($file));
header(“Content-Type: application/pdf”);
header(“Content-Transfer-Encoding: binary”);
if(!empty($_REQUEST[‘pdf_is_download’])){
$pdffilename=$pdffiledate.”.pdf”;
header(“Content-Disposition: attachment; filename=$pdffilename”);
}
echo base64_decode($content);
fclose($transaction);
?>
[/code]

Thank you in advance

to post a comment
PHP

3 Comments(s)

Copy linkTweet thisAlerts:
@ginerjmJul 30.2013 — It looks like you are uploading a pdf file and want to do something with it. (Although - I am confused by your use of the word 'date' in this code.)

What do you mean create a 'temporary file'? Usually when you upload a file you store it somewhere which you are not doing here. Then you can provide a url that points to that location. This would not be temporary either - you would have to delete it at some point if you wanted it to be temporary.
Copy linkTweet thisAlerts:
@AdemauthorJul 31.2013 — Thank you for your answer

This code works

Exsample: www.mysite.com/pdf.php?&#305;d=12

Browser PDF file shows, no problems

I wanted to do the following:

Exsample: [B]Click this[/B], www.mysite.com/pdf.php?&#305;d=12

URL Redirection: www.mysite.com/[B]temporary_url.pdf[/B]

The browser is closed, this url will be unavailable, invalid url

Best Regards
Copy linkTweet thisAlerts:
@ginerjmJul 31.2013 — Don't understand, but good luck.
×

Success!

Help @Adem spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...