Creating Link To File Or Temp File For User Download
I am designing a document management system (DMS). The files are stored
in a directory on the webserver. The filenames for the documents are
stored in a MySQL database. The DMS will track revisions from the
initial version through the updates. We must have strict permissions
set so only authorized personnel can access some documents. All of the
documents when uploaded are given totally random names such as
"114723fb5422c6bd5ed18f6.doc". Is there a way, without the webserver
creating a new file name "document_specs_ver2.doc" to have the file
download named "document_specs_ver2.doc".
If I must physically create a new file, how do I know when the
webserver would be allowed to delete it? Notes: The files will be in
several different file formats, not just "doc".
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Header Function, File Download, Temp File Disappears
I have the following headers: if (preg_match("/compatible; MSIE/i", "$browser_type")){ header("Content-Tranfer-Encoding: binary"); header("Content-type: ".$assoc["type"].""); header("Content-Disposition: attachment; filename="".$assoc["name"].""");} echo $assoc["file"]; which starts the download of an mp3 file in one particular case. If you do not save target as and just select 'open' the temp file is zero bytes even though the download process took a while and showd how much progress you were making. So something is happening to the temp file.
File Creation And Temp Download Time
I am creating a program that is going to make a file populated with at least 20 MB of data and many people are going to be using it. I want the user to be able to download this file for at least 10 minutes and then it to be deleted. Does this have to be done via cronjob or can php write a rule to delete that file after 10 minutes? Because if this was done by cronjob it would have to be set basically to run every minute to get it right on the dot like most website do.
Dynamic Download Link - Not Direct File Link
I'm posting a podcast feed that makes reference to audio files for download. Instead of linking to the files directly (e.g. www.mywebsite.com/podcast.mp3), I want to link to the file as get variables so that I can track number of listeners (e.g. www.mywebsite.com/?audio=podcast.mp3). Where would I look to get something like this to work? How do I start sending audio data to the user using a link like this?
Creating Download Link For A Pdf
Using: Mysql 5.0.15 php 5.1.6 apache 2.2.3 I am trying to create a download link for various pdfs which I have stored in a mysql DB. I am having trouble with the header fields when clicking the link. Here is the code that sends the pdf called using <a href="download.php?id=4">Blah</a> Output is delayed from php.ini (output_buffering = 4096) What http headers should I be sending. This works most of the time like this, but in IE6 I get few strange results sometimes. 1. Clicking on a new page after downloading the pdf - the page is blank unless I refresh 2. The URL in the address bar does not update even though the page does. 3. If I leave out the Content_Disposition header and set the Content-Type: application/pdf. The browser just displays the PDF as text. <?php include($_SERVER["DOCUMENT_ROOT"] . "/../php/common.inc"); include($_SERVER["DOCUMENT_ROOT"] . "/../php/prepend.php"); $db=new Interlex_DB; if(isset($_GET["id"])) { $query=sprintf("SELECT pdf, filename, length(pdf) AS len FROM broadsheets WHERE broadsheet_id='%d' AND active=1", $_GET["id"]); $db->query($query); if($db->next_record()) { if(!headers_sent()) { header("Accept-Ranges: bytes"); header("Content-Transfer-Encoding: Binary"); header("Content-Type: application/force-download"); header(sprintf("Content-Length: %d", $db->f("len"))); header(sprintf("Content-Disposition: inline; filename="%s"", $db->f(filename))); echo $db->f("pdf"); //exit; } } } ?>
File Field Has No Temp Name?
I have a file field to upload a csv file.. on one page it works fine, on another page it returns NOTHING for the temp name... here is the code for the form: <form id="frmAddMusic" name="frmAddMusic" method="post" action="uploadmusic.php"> Upload CSV File of Music: <input name="fleMusicCSV" type="file" id="fleMusicCSV" size="40" /><br /> <input name="Submit" type="submit" id="Submit" value="Upload Music" /> </form> and the code for the upload stuff: set_time_limit(600); echo $_FILES['fleMusicCSV']['tmp_name']."<br>"; $handler = fopen($_FILES['fleMusicCSV']['tmp_name'],'r'); while ($row = fgetcsv($handler,1024,"|",""")) { the echo for the tmp_name returns nothing.. anyone have any idea whats going on?
Delete Temp File On Server
I am using the following to generate an xml doc to the users browser: $fp = fopen("document.xml", 'w+'); $str = ($xml_frame->Fields('top_xml').$content->Fields('xml').$content->Fields('xml').$xml_frame->Fields('bottom_xml')); fwrite($fp, $str); fclose($fp); header( 'Location: https://www.website.com/document.xml') ; I would like to delete 'document.xml' after it has been loaded to the user's browser but unlinking the file kills it before it loads and sleep hangs everything. I there a way to detect when it's finished downloading to the user?
How To Get Mysql Query Result Into Temp. Txt File
I did a lite search in the archive but didn't find anything specific to my problem. Here is what I am trying to do: I've got a table with about 25k entries of company addresses. I need to be able to pull specific data out of the table and put it in a temporary text file and then display the result in the browser for the user to save locally. The query part and the format of the data is all simple enough but I am having trouble figuring out how to get the data from the query into a temporary text file and then displaying that file. here is what I whipped up but it obviously doesn't work: Code: <? $tmpfname = tempnam("/path/to/file/", "FOO"); $list = mysql_query("select * from FH_LIST where State='AK'"); while ($list_results = mysql_fetch_array($list)) { $data = blah blah blah; fwrite($tmpfname, ".$data "); } fopen($tmpfname, "r"); fpassthru($tmpfname); ?> I get an error message saying: Warning: Supplied argument is not a valid File-Handle resource (referring to $data).
Change Default Temp File Upload Area
Hopefully you won't need example code for this. Does anybody know how to change the default file upload temp area on a IIS server (not using .htaccess or php.ini) using PHP?
File With No Link
I have a link on my web page. When clicked, opens up a pdf file that is stored on my server. Every file is specific to a user's user name and I don't want users to see each other's files. For example: When User1 clicks on the link, it opens up http://mydomain.com/files/user1.pdf and when User2 clicks on the link, it opens up http://mydomain.com/files/user2.pdf. So, if User1 knows about User2, he can see User2's pdf file. How can I make the file open up in a different window without the file path in the address bar?
.txt File Download - How?
I'd like to get a prompt for a .txt file download instead of displaying it in the browser. The way things are setup now is that when a link in the nav menu is click it's pointed to download.php:
Download A File Using Php
An affiliate company i work with has a feed they publish, and I'd like to download and save it as a txt file on my server. How can I do this using php? I'm assuming I need write a small script that will get the file on their server, save it on my server (and change the extension to txt). Then I'm going to run this script via a cronjob. Can anyone point me in the right direction to get started on this? I'm not sure which php command I need to use to grab the feed from the other server.
File?download
I have an mpg file which I am throwing on a site for a client to download if he so chooses. I know I could zip it up and let him extract it, but I was essentially looking for how to allow my site to have a link where he could click to download the .mpg file. I have it embedded, and I have it so where they can click the link, and it'll open up a new browser to view it. But I'd rather have them download without having to right click and save as. Any help would be greatly appreciated. The site is done in PHP, and I understood there was a way in PHP to do this.
PHP File Download
I'm making an "online harddisc" type of thing, where the user can among other things upload and download files. But I cant figure out how to do the download to the client. Let me spesify; I can do the download, but the file gets the name of the php-script. Someone said: <quote> make the link thar specifies the script/file like this http://somewhere.com/download.php3/originalfilename.txt?var=anyvariables Then in the script download.php3 put this after doing your processing Header("Content-type: application/RFC822"); readfile($copyfile); </quote> What does dowload.php3/orig.txt mean??? Why the '/'??? And the problem; the browser tries to download 'downlaod.php3' instead... My test file: Code:
File-up- And Download
I`m trying to write a script, to upload files to a server and afterwards the users shall have the possibility to download all already uploaded files. Code:
File Download
I've just set up an apache web server on my Linux system. I would like to allow people to click on a link and download a file (from my server) using a php 4 web page - but i dont want to use ftp to transfer the file (i dont want to run an ftp daemon on my server). Is there an easy way to do this? Also a quick question on security - is there any way a remote user can get to see the php4 code via the web server (ie using only port 80 - assuming the rest of the server is secure etc)?
File Download Through Php
I have a problem when doing indirect download of file through php, when I click on download link Firefox and Internet Explorer give me same options: Open and Save. Firefox opens file directly from Internet and downloads without problem. Internet Explorer saves file on local disk and I can open it from disk correctly but when I try to open it directly from Internet it responds with "There was an error opening this document. This file cannot be found.", concrete situation in my usage is Pdf document. Below is my concrete code, <?php ob_start(); include_once("config.php"); ini_set('display_errors', 'Off'); error_reporting(0); $args = trim($_SERVER["PATH_INFO"]); $args = preg_replace("/^//i", '', $args); $argv = explode('/', $args); $id = (int)$argv[0]; import('dao.fm.file'); $f = fm_file::instance($id); if($f->get('id') < 1) { die('No file.'); } header('Content-Disposition: attachment'); header('Accept-Charset: UTF-8'); header('Content-Type: '.$f->get('type').' charset="UTF-8";'); readfile(get('FILES').'/'.$f->get('id')); ob_end_flush(); ?>
How To Download A File??
i want to create a "download files" system - something like "download.com" - but like "download.com" i dont want the direct link to the file to show i want it to be something like : "http://www.myhomepage.com/getfile.php?id=132" the idea is to optain the id through the "$_GET" and then get the path of the file from the DB ...but then what?the "header()" function wont work unless its the 1st function to be called so i cant query the DB for the file path then call it!! or is there any other function i can use to send the file to the user ?
How To Download A File With Php?
I know how to make a http request with php using CURL extention. My question is "Can I make a http download request to a server from my php script and save it?"
Download A Rar File
As the title says, I'm trying to download a rar file when a button is clicked. So far Images, Videos, and Zip files download successfully. Here are the mime types I've tried using application/force-download application/x-download application/octet-stream application/x-rar-compressed application/x-rar application/x-compressed application/rar None have worked. The mime type that I got from PHP for the file when I uploaded it was "application/x-rar-compressed" but that didn't do a thing :-/ I'll click the download button, it'll ask me to save the file and the download is done instantly. 0kb in size.
File Download
I want users to be able to download a file. Its all working. When the user clicks the link the windows "File download" box pops up asking if the user wants to save/open etc. Press save and the file will save. However, the estimated time left says "Not known 1.4Mb downloaded" etc. How do I get it to show the estimated time left - i guess its something to do with fetching the actual file size from the server? Code:
Download File
function downloadFile($thefile) { header ("Pragma: public"); header ("Expires: 0"); header ("Cache-Control: must-revalidate, post-check=0, pre-check=0"); header ("Cache-Control: public"); header ("Content-Description: File Transfer"); header ("Content-Length: ".filesize($thefile)); header ("Content-Disposition: attachment; filename=".$thefile); header ("Content-Transfer-Encoding: binary"); $fopen = fopen($thefile); fpassthru($fopen); fclose ($fopen); } Ok why when the file download box comes up with the correct file path passed to the function, does it download the file but it wont open images etc, and text documents come up with a load of rubbish or they display some of the code from the download page.
File Download
I have a small script that does a 'force download' of a pdf file - the problem is while it downloads the correct file, when I attempt to open the file once download it is corrupted - I get the following error in Adobe Acrobat: "There was an error opening this document. The file is damaged and could not be repaired." Code:
Download .pdf File
I have successfully uploaded adobe .pdf's to a mssql 2005 server but now I am having issues downloading the file. in IE The download window will pop-up and ask to save or download. if Download is chosen it will begin the transfer but stalls and says connect to server timeout. if I open it I get binary description of the file. in Firefox The download window appears but the OK button is disabled. I have been searching for different methods of downloading the file and here is the code that I have: The file I am testing is only 213KB Code:
Download File
The following code, uploads an MP3 file to a folder located in the root directory of the server, whilst adding the files path to a database. For each record in the database, how do I display the path as a link and upon a link being clicked, download the file? Code:
Log Url Link Throughs To File
I'm putting an advert onto my company website and the client has requested to know the amount of traffic the advert attracts (a click through). How can I incorporate php to log all click throughs to a file on the server for the client? Can I use something like this? http://www.dynamicdrive.com/forums/archive/index.php/t-5341.html
Play MP3 File Through Link
I have the following code, that uploads files to a "Upload" directory on the server, and stores the files path in a database. Code:
Creating Pdf File
Is it possible to create a pdf file from a HTML form. i want to create a pDF file from HTML form which looks like the scanned copy of HTML form. I hope there must be somebod< who can answer this question.
Help In Creating XML File From DB
Hi friends i need to get the details from two tables for creating one XML file.. for that, first i started by defining a DOMXML object $doc = domxml_new_doc(Ƈ.0'); and i have one outertable query as $outer_table = 'main_category' $query = "SELECT * FROM $outer_table"; $resouter = mysql_query($query, $mysql_connect); and when its first row is read its creating elements by $child = $doc->create_element($fieldname); $child = $outer->append_child($child); $value = $doc->create_text_node($fieldvalue); $value = $child->append_child($value); and i need to get some details from second table with its subcategid=maincategid to do this i need to get that particular field that alrady appended to the xml How i can..... i tried get_elements_by_id() but it returns only those elements that comes under it.]
Forced File Download Changes Its Name
I couldn't find anything in previous posts about this, but i would have thought it was a common issue. Basically I have a dynamically generated PDF file - which gets pushed to the user as a download when tney click on an <a href...> link. To force the PDF to download I use the following headers:
Getting A File To Download And Not Display
I am having real trouble getting a file to download and not display in the browser, if it is of file type which is displayable in the browser. I have tried to do this with the following script: $filename = "sample.pdf"; $filesize = filesize("path to file on server"); header("Content-type: application/x-msdos-program"); header("Content-Length: " . $filesize); header("Content-Disposition: inline; filename=$filename"); readfile("path to file on server") or die("Error Downloading File"); Ok, I have used this script before on a different server and it ran fine, however on the server I now work on, it opens the file in the browser(in what looks to be binary!).
File Download Issue
Does anyone know how to monitor the status of a file being downloaded from a php script? I have a file management system that checks out a file when a user goes through certain steps. I would like to eliminate some of these steps by monitoring whether or not the file is fully saved or the save as process is canceled. Any ideas?
Download File, Or Stream?
Is there a way with php using headers for example to cause a file, such as an mp3 to be downloaded, instead of IE trying to play the file, or winamp launching up and playing the file? I have some headers that output various kinds of files:
JPEG File Download Via PHP On Mac(IE)
I am trying to download a JPG file through a php page. The code is pretty straight forward, it obtains the filename from the query string, reads the file and outputs to the browser. Here is the code: <?php $filename = $_GET["file"]; $bytes = filesize("PATH_TO_FOLDER/$filename"); header("Content-type: application/jpg"); header("Content-disposition: attachment; filename="$filename""); header("Content-length: $bytes"); //Read the file and output to browser @readfile("PATH_TO_FOLDER/$filename"); //Code to record the download in database ?> Originally I had "Content-type: image/jpeg"), but later on changed to "application/jpg" after reading through some forums on web. Both the content-types work fine in all browsers on a Windows PC, but they behave very differently with IE5.2 on MacOSX and IE5.1 on Mac OS9. The "Save As.." box does not open and the image gets displayed directly on the window. If I try to save the image by Ctrl+Click and Download to Disk, it shows the filename as "download.php" instead of the correct name "FILENAME.jpg" given in the Content-disposition header. I did a lot of google and read in several forums that IE on Mac ignores the Content-disposition header. Is there any workaround for this. My aim is to display the "Save As.." dialog box on Mac IE (OSX and OS9), display the correct filename in the save as dialog box and allow the user to save the file through the dialog box. (In Mozilla (Mac) it will download the file (but you have to be very quick as it tends to close the "What should Mozilla do with this file?" dialog quickly if you don't select the 'save' option and click 'ok'). Safari seems to be the only browser happy to download a .jpg file onto the disk.)
File Download Quirks
I have a php script that allows users to download files they selected earlier in the session. I use the following code snippet to do this: ## set up headers header("Content-type: application/x-gzip"); header("Content-disposition: filename: $filename"); header("Filename: $filename"); header("Content-length: ".filesize("private/$filename")); ## now send the contents @readfile("private/$filename"); The problem is that the downloaded file gets named as this php code's file name, and not the actual file name. I mean, if the php code is in a file named process.php and the file the users download is myfile.zip, the browser chooses to save the file as process.php.gz.
Forcing A Download Of A File
I would like to force users to download a file to their computer (instead of viewing it within the browser). I would also like to keep the location of the file hidden, so the address would be something like "download.php?id=34" I am thinking I can use something like this: Code:
Offering A File For Download
I am trying to offer a URL to an Acrobat file, which instead of bringing the file up in the browser, offers it for download.... I believe it is a certain header type that I need to send to the browser to bring up the "Save to Disk" dialog box but am not sure...
File Download Problem - I.E.4.02 SP2
I have a form for user to download files from the intranet. The script works on Netscape 4, Netscape 6, I.E. 5.5. SP2. The problem is that the majority of our browsers( 200 something) are still I.E. 4.02 SP2. (128 bits) Code:
PHP Cron Job File Download
I go to a website once a week to download public data. Upon submitting a form, a text file is producted and I get the usual Windows dialog box asking if I would like to open or save the text file locally. I save it locally. I am thinking about setting up a php script on an Apache server I use to host some websites. Basically, I would like the script (which is nothing more than a pre-populated form) to run as a cron job, get the text file and then email it to me. My questions: (1) Is this possible and (2) If so, if the form is submitted from the server, where does it get saved? And what will it be named?
File Download Using Header(), Over SSL
I've got a web-based report that is downloadable into a .csv file for Excel. The script that sends the data for download goes something like this: PHP Code:
Starting File Download
Is there a way to make a browser start downloading a file, automaticly, no matter what type of file it is?
How To Hide The Url Of A File For Download
I'd like to let user download a file but I'd like to hide the url of the file. I'd like to write something like that: <a href="download_file.php?id=1123">download file</a> download_file.php get the file and give it to user. BUT....... how can I write download_file.php?
File Download NOT Open
I have a php page that reads files links from a Database. This works well, but when we click on the link the file starts to open. Is there anyway to force the file to SAVE not open ?
Outputting A File For Download
im trying to let a user download a file from my website, for example a picture. i dont want the user to have to right-click and do save-as, but instead i want a window to popup (the window with "Save File","Open File","More Info",etc) so that the user can download it easily. i have a feeling this has something to do with headers, but i have no idea what the correct headers are.
PHP File Download Counter
I use htaccess to protect directory and granting access to download file only for the authorized users. Just want implement simple PHP file download counter for single file. I need track the number of downloads of this file on my website, IP address and date. Since I have no access to Apache log files, I need some other way, use script that will write a log file. Is there some handy way?
Finished File Download
I am not sure if php can achieve this, but i guess that my problem shoulb be solved with an server side language. Is there any way i can tell if a visitor of my website has finished a download? For example the visitor clicks on a file download link, and when his download is finished then i want to happen something (for example some download counter or something like that.)
Error 500 And Download Php File
when i execute php files in folder other than the document root, i get error 500 and the php file is downloaded to my browser with the 500 error code. I think it could be related to my modules. or my folder options LoadModule perl_module modules/mod_perl.so LoadModule cgi_module modules/mod_cgi.so LoadModule authz_host_module modules/mod_authz_host.so LoadModule autoindex_module modules/mod_autoindex.so LoadModule alias_module modules/mod_alias.so #LoadModule python_module modules/mod_python.so LoadModule php5_module modules/libphp5.so LoadModule mime_module modules/mod_mime.so LoadModule negotiation_module modules/mod_negotiation.so LoadModule userdir_module modules/mod_userdir.so LoadModule dir_module modules/mod_dir.so LoadModule vhost_alias_module modules/mod_vhost_alias.so LoadModule log_config_module modules/mod_log_config.so LoadModule ssl_module modules/mod_ssl.so LoadModule setenvif_module modules/mod_setenvif.so ScriptAlias /testscript "/usr/local/test/public/testscript" <Directory "/usr/local/test/public/testscript"> Options Indexes FollowSymLinks MultiViews Includes +ExecCGI AllowOverride ALL Order allow,deny Allow from all Options +ExecCGI </Directory>
|