witt Posted June 23, 2006 Share Posted June 23, 2006 I've tried several different methods an none have worked so far. Basically what I want is to a have a script named download.php that gets passed a file id via a link and then prompts the user with the option of saving the file. Retrieving the information for the file in question is not a problem, just the downloading part. Lets say that file name, file type (pdf in this case), file size and file location are already at your disposal, all that is needed is the code to prompt the user to dowload the file. Quote Link to comment https://forums.phpfreaks.com/topic/12769-downloading-pdf-files/ Share on other sites More sharing options...
AndyB Posted June 24, 2006 Share Posted June 24, 2006 [a href=\"http://www.phpfreaks.com/forums/index.php?showtopic=95433\" target=\"_blank\"]http://www.phpfreaks.com/forums/index.php?showtopic=95433[/a] - you may find that useful Quote Link to comment https://forums.phpfreaks.com/topic/12769-downloading-pdf-files/#findComment-48943 Share on other sites More sharing options...
witt Posted June 24, 2006 Author Share Posted June 24, 2006 [!--quoteo(post=387322:date=Jun 23 2006, 07:11 PM:name=AndyB)--][div class=\'quotetop\']QUOTE(AndyB @ Jun 23 2006, 07:11 PM) [snapback]387322[/snapback][/div][div class=\'quotemain\'][!--quotec--][a href=\"http://www.phpfreaks.com/forums/index.php?showtopic=95433\" target=\"_blank\"]http://www.phpfreaks.com/forums/index.php?showtopic=95433[/a] - you may find that useful[/quote]Unfortunately I don't. I get the same result as I've gotten with everything I've tried - the pdf gets corrupted and can't be opened. Quote Link to comment https://forums.phpfreaks.com/topic/12769-downloading-pdf-files/#findComment-48965 Share on other sites More sharing options...
litebearer Posted June 24, 2006 Share Posted June 24, 2006 (1) May we see your code.(2) What happens to the pdf file if you simply make a link to it?ie[code]<A href="some.pdf">Click Me!<?a>[/code]Lite... Quote Link to comment https://forums.phpfreaks.com/topic/12769-downloading-pdf-files/#findComment-48966 Share on other sites More sharing options...
witt Posted June 24, 2006 Author Share Posted June 24, 2006 Hmm, now I get this:An appropriate representation of the requested resource /forums/index.php could not be found on this server.when trying to reply.Here is the code I had:[code]header("Content-type: $file_type");header("Content-Disposition: attachment; filename=$file_name");echo $file;[/code]This was used to display files retrieved from the database. The strange thing is that the above code stopped working 2 days ago and now all pdf files are corrupted. Anyways, I'd rather have the files downloaded from the server instead of the database....and this:..and probably a about another 5 things. The pdf file always end up getting corrupted. I have no idea why the first code worked, and then suddenly stopped working today. It leads me to believe that some of the php settings were changed on the server, but I'm not sure. If I simply link to the file I get prompted with the option to download and the file opens fine after it.I tried a few other things, but for some reason I get an error why I try to post it in this message. Quote Link to comment https://forums.phpfreaks.com/topic/12769-downloading-pdf-files/#findComment-48968 Share on other sites More sharing options...
witt Posted June 24, 2006 Author Share Posted June 24, 2006 Any ideas? Quote Link to comment https://forums.phpfreaks.com/topic/12769-downloading-pdf-files/#findComment-49067 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.