Forcing Downloads With A Code
i have a problem with forcing downloads with a code like the following or some similar:
$filename = $fileName;
$size = filesize("$filename");
header ("Content-Type: application/octet-stream");
header ("Content-Length: $size");
header ("Content-Disposition: attachment; filename=$filename");
header ("Content-Transfer-Encoding: binary");
readfile($filename);
i think, normaly the code is ok, but whenever i use something like this on my system (win2k/apache and freeBSD/apache) it works only with rightcklick. using normal leftclick, the downloadbox shows (and even downloads) me only the name of the source page (filemanager.htm) or rather the html-output of the base-script.
View Complete Forum Thread with Replies
Sponsored Links:
Related Messages:
Forcing Downloads
Trying to use PHP to download a pdf from server to local machine. Got the following: $bs = Singleton::getInstance('BrowserSniffer'); $file = $_SERVER['DOCUMENT_ROOT'] . '/pdf/' . $location; $filename = substr(strrchr($file, '/'), 1); if ($bs->name == 'Mozilla') { $content_type = "application/octet-stream "; $attachment = ' attachment; ' } else { $content_type = "application/download "; $attachment = ' ' } header('Content-Type: ' . $content_type); header('Content-Transfer-Encoding: binary'); header('Content-Disposition: ' . $attachment . ' filename=' . $filename); header('Content-Length: ' . filesize($file)); $fn = fopen($file, 'r'); fpassthru($fn); But cannot get the file to download if $location has spaces. Is there any way around this?
View Replies !
View Related
Get Top5 From Downloads Based On The Downloads Counter?
me doesn't know how to get a Top5 download list from MySQL I have a table called downloads with the fields - dl_id - dl_userid - dl_name - dl_genre - dl_url - dl_downloads (has the number on how many times the file is downloaded) Now I want to show the Top5 downloads based on the dl_downloads and that I can show all information (filename, userid etc) in a table. ?
View Replies !
View Related
Forcing The Download Box
I have a page that generates a text file (but writes the file with the ".csv" extension) and then I redirect the user so he can save the file header("Location: $my_csv_file"); However, the file appears as text in the browser and I would prefer that the gray "Download this file" box pop up. How could I pull this off, or is this really more dependent on client browser settings?
View Replies !
View Related
Forcing Frameset
Is there a way of forcing a document to be a part of a frameset. Search engines sometimes point to a single frame of my whole frameset. Something like: of main.php is not inside a frame it redirects to index.php.
View Replies !
View Related
Forcing The User
The user logs in to a certain webpage (username & password). Then the user sees a html page with a link in it. This link is a target="_blank" link, so it would open in a new Internet Explorer window. Normally the user has the possibility to go on that link (without clicking with left mousebutton), pressing the right mouse button, going on copy location, open a new browserwindow by himself (even if it is a totally other browsertype), copy the link location in it, and access the url of the link in this manner. I want to prevent this. He should only be able to open the link by pressing the left mousebutton, otherwise he should have to log in again. Is this possible, if yes - how?
View Replies !
View Related
Forcing Round()
I'm using a webservice to query for currency conversion rates and this returns me a value which I use round() on like round($string, 2) to force two chars behind the comma, but it doesnt output a trailing zero if there is one eg, it will return 124,1 instead of 124,10.
View Replies !
View Related
Forcing Browser
This is something im really struggling with. I have a txt file called text.txt on my server which I am wanting to force the browser to download. No matter what I try it just displays the contents of the file.
View Replies !
View Related
Forcing Download
I have files that people purchase (3D Studio Max files, that get opened by software that they have installed on their computer). I want the following. After they've purchased, they will have access to the files to download. However when they click on the file, it should only allow them to open the file (in the software program that they've installed on their computer - i'm guessing the Operating System will handle this). Code:
View Replies !
View Related
Forcing Server Mode
I've been through the docs and I'm more than a little confused: I'd like to run [some] PHP apps as ordinary CGI programs. I though/hoped there'd be a command line switch [that I could put in my shebang line] that'd tell PHP to run in SERVER mode, but I couldn't find it... Is there a way to do that? [meta question: is there a way to get Apache to use mod_php on a shebang'ed PHP program... that'd be best, of course..:o)]
View Replies !
View Related
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:
View Replies !
View Related
Forcing Download Dialog
I'm using this code to force browser's download dialog.I have problem only with IE 6 because the downloaded file size is 0 bytes.Does anyone know why? $fp=fopen('c:xampphtdocspesmeR.E.M.-Losing_My_Religon.mp3','r'); $name=basename("c:xampphtdocspesmeR.E.M.-Losing_My_Religon.mp3"); $size=filesize('c:xampphtdocspesmeR.E.M.-Losing_My_Religon.mp3'); header('pragma: cache'); header('pragma: public'); header('Content-Type: audio/mpeg'); header('Content-Length:$size'); header("Cache-Control: private",false); header('Cache-Control: max-age=0'); header("Content-Transfer-Encoding: binary"); header("Content-Disposition: attachment;filename= $name"); fpassthru($fp); fclose($fp);
View Replies !
View Related
Forcing The User To Type
I have not been able to find the answer to this on the net. I want to force the user to type in text into a text field and not be able to paste in text. This is for confirmation fields. How can I do this?
View Replies !
View Related
Forcing Upload Of Files
I have set up a php script that forces upload of an excel file by the user, thus: header("Content-type: application/octet-stream"); header("Content-Disposition: attachment; filename=data_".date("d-m-y").".xls"); header('Cache-Control: public'); header("Pragma: no-cache"); header("Expires: 0"); echo $thedata; This works perfectly, except when I move the script to my secure connection. At that point, Firefox will download the file, but IE says it doesn't fine it.
View Replies !
View Related
Forcing Function Timeout
is there any way to force a function in php to timeout. We're getting data from an external source using file_get_contents() with a URL but when its down it can take up to 2 minutes to come back and say its down.
View Replies !
View Related
Forcing Secure Page (https)
I am a novice at secure pages (just installed mod_ssl and open_ssl). The main question I have: If a page is "secure" (https://blah) and you don't want people to get there by typing http://blah, how to you stop that? I want users to login, but I want the login to be https://domain/login.php not http://domain/login.php. How do I stop someone from being able to access the login page insecurely?
View Replies !
View Related
Forcing Queries/php To Refresh Page
let's say I have a page listing records in a table... If I go somewhere else and later on reload this list page, it does NOT refresh the list (if more records were added to the table meantime). What should I do? Is there a way to force a refresh? If I turn off the cache, are people still going to be able to cache the graphics (i don't want to force a reload of every element, just the page itself)?
View Replies !
View Related
File Empty When Forcing Saveas
I am trying to force saveas using array for filename. The problem is that when I click saveas or open, the file is empty. The path to the file is fine, and the file is in the correct directory. However, when the filename is hard coded, the file is fine.
View Replies !
View Related
Forcing A Web Browser To Stay Open
I recently developed stock check system which involves an admin panel that refreshes every thirty seconds to check for new additions to a database. If there is a new addition then a buzzer will sound alerting individuals that action should be taken. This is where the problem lies however, the computer that runs the webpage that refreshes every thirty seconds is a community computer. People keep closing the page by accident thus rendering the system useless since the buzzer will not sound. Is their any way to check and see if Mozilla or internet explorer are open, and on a certain page? Is their any sort of toolbar system that could easily be used to run the page minimized. How hard would it be to make a .exe file to check the database?
View Replies !
View Related
How To Display Text On Browser After Forcing Download
how do i display text to my browser after i force a download? heres my working script: Code: $selected_file = "/home/user/somelogfile.log"; header("Content-Type: text/plain"); header("Content-Disposition: attachment; filename=" . $_SERVER[HTTP_HOST] . "_" . $selected_file); header("Content-length: " . filesize($selected_file)); readfile("$selected_file"); what i want to do is display some text in my browser, but if i echo something after readfile(), it gets included in the download file, while i also cant echo before the download as headers need to be sent before any text .
View Replies !
View Related
Forcing A Line Break In An Email Sent Via Php Form Script
I've successfully created a script which sends an email when the form is filled out. (yay!) But I am not happy with the formatting of the email once I receive it. I have 10 variables passed in the email, and some of them are on a new line, but some are all on the same line. Is there a way to force a line break after each line, so there is only one entry per line? Or perhaps a way to send this as an HTML email so I can put the variables in to table cells? example of what each line looks like: "Last name: ".$_POST['last_name'] . " " .
View Replies !
View Related
Visitor Stats... Forcing Uniquness (IP/Date.Time)
Im setting up a DB to collect visitor data... i want it to be unique based on a 24 hour period for giggles lets say i have this stored in my db (completely hypothetical) 127.0.0.1 | Mozilla | NT | 1.8 | 11:30pm now lets say i refresh the page... what would my query look like such that it would check to see if what im trying to enter is unique by IP and date/time the time bound would be midnight to midnight, not 24 hours after the first appearance of a given IP address (this way i have accurate daily collection based on my servers timezone) i already have the data collection taken care of... its just accurately entering it into the DB
View Replies !
View Related
PDF Downloads
if any one could help me on a PHP coding issue with PDF downloads. I have a link to a PDF file on a website, BUT when I click on it, the link directly opens the PDF document. I expected it to, first, prompt me with the usual grey box that gives the option of either directly opening the document OR saving it to a location on the computer. How do I do this ? I was told that it is a piece of PHP code, but what code would I need and how where would it go for the link to work this way ?
View Replies !
View Related
Downloads
if there was some kind of script (or if it is scriptable + how?) to make a link automaticly download multiple files so. When you click on 'download' it downloads like 20files after each other;user has to do nothing but wait (so no clicking on 'next download' or anything). Is this possible (so to download multiple files at once when clicked on download).
View Replies !
View Related
Where To Get Downloads
what is the module name I am looking for the script or a script that I can use and edit to achieve the following? I am looking for a module where you can add details of a place you visited, Example: Select and display country - state - city - places - place description. I don't know what this kind of directory or script is called. It must just be editable by admin but if login users can add too that will not be a problem.
View Replies !
View Related
Downloads From Server
How do I download files (e.g., Windows executables) from a Linux server to the user's workstation? I would like to let the user browse his/her workstaion for the directory to drop the downloaded file in.
View Replies !
View Related
Secure Downloads
I am currently working on a project with a very secure feel to things (SSL, password only, etc, etc), it's an extranet site. I need to generate PDF files for the clients to download. I have made my own session management system which tracks, by IP address, and changes the Session ID every page, but I need to allow the users to download the PDF files securely. I have a few ideas so far: 1) Generate the PDF files in a directory not accessable by apache, and then enter a row into the MySQL database saying this session/user has a PDF to download. Then a link can be shown to the user, such as /downloads/Report.pdf?SID=<Session ID> (where SID = Session ID). I could make all .pdf files be processed by PHP (therefore act like a PDF in the /downloads/ directory), in the apache config. When the Report.pdf is run it checks the SessionID, then looks in the database for a valid PDF file, and then reads the file straight out to the client. Will this work? Any ideas/suggestions? 2) Justr make the PDF file on the fly, but this will have problems with users who want to be able to save the PDF file. I'd like to go with option1, but I'm not too sure whether this will work. This is not just related to PDF files, it can mean any file type (and I will also need to do a similar things for .zip, and .csv later on) Any suggestions please. I dont want the PDF files saved into a /downloads/ directory on the server, as some1 in theory could take the file, and to make this not the case/harder to do, the filename would have to be very very long... and random gemerated, which is not nice for the client.
View Replies !
View Related
Resume Downloads
I want send my zip files in my page from inside php. With this I know how many people have download my file and other information. My problem is this, I have this code but it dosn't resume broken downloads. What I can do for this? ------------------- <?php header('Content-type: application/zip'); $fp = fopen('file.zip', 'rb'); while (!feof($fp)) echo fread($fp, 1024); fclose($fp); ?> ---------------------
View Replies !
View Related
Members Only Downloads
Just wondering if anyone knows of a script that will perform (at least most of) the following tasks: 1. Hide the files actual location from the user (possibly not needed as I can store files outside of wwwroot). 2. Manage users who are allowed to download the file(s) 3. Will show all files in the folder for download without needing to set a link to each file manually I can do the first two myself if there are no scripts readily available, however, the third, I'm not sure on.
View Replies !
View Related
PHP Coding For PDF Downloads
I was wondering if any one could help me on a PHP coding issue with PDF downloads. I have a link to a PDF file on a website, BUT when I click on it, the link directly opens the PDF document. I expected it to, first, prompt me with the usual grey box that gives the option of either directly opening the document OR saving it to a location on the computer. How do I do this...? I was told that it is a piece of PHP code, but what code would I need and how where would it go for the link to work this way..?
View Replies !
View Related
Use PHP For Non-anonomous FTP Downloads
I am having a problem creating a simple ftp download for users. For some files it works, and for others I get a long pause. The final goal is to have a form button, when clicked, behind the scenes it logs into ftp, and gets the file. I then pops up a download box (the standard save as.. box) I need the user to not know what the path is, and I want to not allow anonomous FTP. Is there an easier way to achieve this? Code:
View Replies !
View Related
Auto Downloads
from what I can tell you can use header statements to trigger downloads when a page is loaded. Is there a list somewhere of the content types? Or is there a better way to trigger a download?
View Replies !
View Related
PDF Downloads Using Readfile()
I'm using a PHP script and mod_rewrite to serve files: The page address is of the form: http://www.example.net/get/<file_id> and the following headers are sent: header("Content-Disposition: attachment; filename="$filename""); header("Content-Length: $filesize"); header("Content-Type: $filetype"); readfile($file); exit(0); The problem (for one of our clients) is that this always forces a download prompt. I tried adding: header("Cache-Control: public, no-cache"); but it had no effect.
View Replies !
View Related
Downloads By Date
I need to store a download date in a MySQL Database when a user makes an order, and check to see if that download date has expired when the user logs in in the future. What would be the best way to do this? timestamp? Is there a PHP function that can anaylze the timestamp (or some sort of date string) and check to see how much time is left? Example: User orders download access for 24 hours - Comes back 5 hours, 20 minutes later - It should tell him that he has 18 hours fourty minutes left. I just need help on the timestamp/php date/math function. I've got the database queries down.
View Replies !
View Related
Whole Directory Downloads...
I have all my files being listed in a view(browse) script, and i want it so instead of having to download like every single file, u can just click an option that's like 'download whole album', and it reads every file in the directory and begins downloading them all... any suggestions where to get started with the php :/. never done anything regarding downloads.
View Replies !
View Related
How To Count Downloads?
I have a script which stores binary files and metadata i mysql. The files are downloadable by clicking on their name in the output. Is it possible to count the number of download on each file? Matters worse: Files are stored in four categories and each category might have the same file name but different content.
View Replies !
View Related
Downloads Manager
I've just recently been learning PHP, and decided my website needed a nice simple downloads page. At first I made a very simple one, with nothing but a page that meta refreshed to the download and logged the number of downloads, and then I added a way to look at all the downloads, and then I added a way to view info for each download. Before I knew it, I had a fully-fledged downloads manager on my hands, with a rating system as well. Currently all the information and logs for the downloads is stored in text files, which I realise is not a great way to do this, but I have no experience yet with SQL databases, and I'm really not sure how I would go about that.
View Replies !
View Related
Downloads New Query
I read a few posts and some are incomplete and rather old, but I have at least trawled the forums to find relevant information.I am learning php to work with mysql. I have a few pages working and added secure pages to my database to accept secure logins. However, the purpose of doing so is to provide a few files for download to members only. I am not interested in using mambo or joomla at all. What I can't figure out is, to keep the files secure, do I add them to the database itself, or use a referal to a hidden directory? Right now the files are simply in htdocs, which is a long way from where I want to be! Anyone can access these files. To begin understanding this, I would like to know the correct format before the code. Where should the files be, and what stops a user simply opening that directory in a browser? Can my system link to a directory for the download outside of htdocs?Then what topic am I looking for to research the code?
View Replies !
View Related
Calculate Many Downloads
I want to know how many successful downloads from website, is there some PHP script can do this? Let's say I have file "abc.zip" people can download, The system is Apache+linux+php+mysql, how I can know exact how many successfully downloads and the download time. I know it can be done by weblog statistic, but I want to know is there some way in php can do it so I can save in database and view real time result.
View Replies !
View Related
Downloads Auth
I'm trying to figure out how to only let someone download a file on my server by clicking a specific link on the site, and only let them download it if their user account is allowed to. Any way to control who can and can't download a file using php.
View Replies !
View Related
Track Number Of Downloads
Can anyone suggest a simple way of tracking how many times a given file has been downloaded? It doesn't have to be fancy, just a ball-park figure would be OK? The option I've come up with so far is to have a download page for each file, with the actual file for download on it, and track how many times that page is visited. Not perfect, though; are there are any better approaches?
View Replies !
View Related
Big Problem, SSL Downloads Php Files, Help!
I have my domain in shared host (apache,php 4.12, Mysql). PHP is installed as module and I have SSL certificate as well. For example I have test.php with only <?php print"hello"; ?> If I type in browser http://mydomain.com/test.php it prints hello, but if I type https://mydomain.com/test.php it DOWNLOADS a php file with all code inside!! How this can be possible? Finally I downloaded all my php files to my hard disk with complete code inside, terrible!!
View Replies !
View Related
Header Sometimes Displays Sometimes Downloads
using Javascript - open a new window: $s=contents of database field in rtf format header("Content-type: text/rtf"); echo $s; This works perfectly in Safari (Mac browser) but in both Netscape and IE5 it tries do download. If I use: header("Content-type: text/rtf"); it downloads in all browsers. I have two questions: 1. How do you know which behavior to expect (download or display) 2. I want to display an RTF file in a browser window. Is there a way to do it that works in IE and Netscape?
View Replies !
View Related
Single Click Downloads
How do I ptogram with PHP a link that when clicked starts downloading the file? Basically I dont want to link directly as I want to take note of the number of times a file is downloaded so I need some way of sending the file back to the browser after I have done some housekeeping.
View Replies !
View Related
Counting Downloads With PHP & MySQL
I have a PHP file that offers a file for download. What I want to do is update a MySQL table with the download event. Something like filename - date - time I know how to update the data table but need to kick of the update routine from the <a Href...> link.
View Replies !
View Related
Resuming Forced Downloads
I'm using a script (see below) to force download of video files. The issue that I'm having is that, in the event of a failed download, you can not resume the download (you can, however, pause and resume a download). Does anyone have any ideas as to how this might be resolved? PHP Code:
View Replies !
View Related
|