Force Download PDF code - getting "could not open" error

Hello I am having some trouble with some "force download" code. I have spent many days on google looking for a good tutorial / script but there appears to be issues with everyone of them that I try.
I came across a simple one that I got sort-of working, however the PDFs that it downloads error for some reason. The PDF when trying to open (in adobe reader) produces the following error:
Could not open '3GLG534WW.pdf' because it is either not a supported file type or because the file has been damaged (for example, it was sent as an email attachment and wasn't correctly decoded).
My website with an example download link is: http://www.reese-test2.co.uk/3GLG534WWc.php - click on the green button on the download tab
Does anyone know what I need to alter to get it to work? code below on my script (downloadSPECS.php) and underneath that the code on the actual link to the PDF
The script code (downloadSPECS.php) :
<?php
$pdf = substr($_SERVER['PATH_INFO'], 1);
if(preg_match('/^[a-zA-Z0-9_\-]+.pdf$/', $pdf) == 0) {
  print "Illegal name: $pdf";
  return;
header('Content-type: application/pdf');
header('Content-disposition: attachment; filename=' . $pdf);
readfile('http://www.reese-test2.co.uk/Downloads/Specs' . $pdf);
?>
The code on the green button / PDF link:
              <p><a href="http://www.reese-test2.co.uk/scripts/downloadSPECS.php/3GLG534WW.pdf" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('SpecDL','','images/specDLB.jpg',1)"><img src="images/specDL.jpg" alt="Download Spec Sheet" width="196" height="71" id="SpecDL" /></a></p>
              <p> </p>

Hi thanks all for your answers.
The PDF is def ok. you can see it fine when you put the PDFs address in the browser:
http://www.reese-test2.co.uk/Downloads/Specs/3GLG534WW.pdf
I changed the 1 to a 0 but got a "illegal name" error
I have tried a few other things like adding the extra parts to the script (see code below - ob_clean and flush): Still not working though!
I have tried changing the readfile location - adding public_html and tried a few other things, but cant make it work! Could there be a file size problem maybe? is there a code to allow for this?
thanks
Sara
<?php
$pdf = substr($_SERVER['PATH_INFO'], 1);
if(preg_match('/^[a-zA-Z0-9_\-]+.pdf$/', $pdf) == 0) {
  print "Illegal name: $pdf";
  return;
header("Cache-Control:  maxage=1");
header("Pragma: public");
header('Content-type: application/pdf');
header('Content-disposition: attachment; filename=' . $pdf);
readfile('http://www.reese-test2.co.uk/public_html/Downloads/Specs' . $pdf);
ob_clean();
flush();
readfile($file);
?>

Similar Messages

  • Hello guys my problem is that when I go to run the setup of cloud crative not let me install and I get could not open the installer

    hello guys my problem is that when i go to run the setup of cloud crative not let me install and i get could not open the installer

    Please read https://forums.adobe.com/thread/1499014
    -try some steps such as changing browsers and turning off your firewall
    -also flush your browser cache so you are starting with a fresh browser
    http://myleniumerrors.com/installation-and-licensing-problems/creative-cloud-error-codes-w ip/
    http://helpx.adobe.com/creative-cloud/kb/failed-install-creative-cloud-desktop.html
    or
    A chat session where an agent may remotely look inside your computer may help
    Creative Cloud chat support (all Creative Cloud customer service issues)
    http://helpx.adobe.com/x-productkb/global/service-ccm.html

  • Could not open error log file ''. Operating system error = 5(failed to retrieve text for this error. Reason: 15105).

    Hello
    When I try to start the SQl server service i get the following error:
    Event id 17058
    Could not open error log file ''. Operating system error = 5(failed to retrieve text for this error. Reason: 15105).
    As a test I have made sure the errorlog file ,and the entire drive it is, has everyone full control permissions, but to no avail. Does anyone have any ideas to resolve this issue?
    Thank you

    Hi,
    Try running:
    SELECT SERVERPROPERTY('ErrorLogFileName')
    Then verify that the account being used to run the SQL Server service account has access to the path output above.  If possible, you could try logging onto the server with the same account used to run SQL Server then navigate to the errorlog folder.
    Thanks,
    Andrew Bainbridge
    SQL Server DBA
    Please click "Propose As Answer" if a post solves your problem, or "Vote As Helpful" if a post has been useful to you

  • SQL Server not Starting Up - Could not open error log file system error = 5(Access is denied.)

    Hi guys,
     I am working on issue with SQL Server 2008 R2 .. we rebooted the server and after that all SQL services is not coming up. below is the error from eventlog...
    SQL Server running under NetworkService account and has full control on this files..
    from Config Manager ....
    The request failed or the service did not respond in a timely fashion....
    From Event log..
    initerrlog: Could not open error log file 'C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\Log\ERRORLOG'. Operating system error = 5(Access is denied.).
    Any idea or workaround..?
    Thanks..
    Please Mark As Answer if it is helpful. \\Aim To Inspire Rather to Teach

    Finally I found solution and was able to bring back online the SQL Services...
    I had a very similar issue with the following error (event log):
    Description:
    The SQL Server (MSSQLSERVER) service terminated with service-specific error 17058 (0x42A2).
    For more information, see Help and Support Center at http://go.microsoft.com/fwlink/events.asp.
    Event Type:      Error
    Event Source:      MSSQLSERVER
    Event Category:      (2)
    Event ID:      17058
    Date:            19/05/2012
    Time:            10:20:14
    User:            N/A
    Computer:      NSQLXX
    Description:
    initerrlog: Could not open error log file 'C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\LOG\ERRORLOG'.
    Operating system error = 5(error not found).
    In this case the ERRORLOG file had been marked as read only. This was following a scheduled automated boot.  -This
    was culprit
    MSSQL wouldn't not start until this file had been changed.
    http://www.experts-exchange.com/Database/MS-SQL-Server/Q_23951723.html
    Thanks everyone for your kind replies and time...
    Please Mark As Answer if it is helpful. \\Aim To Inspire Rather to Teach

  • PDF download in 3.1 fails with "could not open" error

    Just created a couple interactive reports and was truly dazzled by the functionality. But when I try to download to PDF, Acrobat Reader 8.1.1 errors with msg "... could not open <file> because it's either not a supported file type or because the file has been damaged...."
    No problem with CSV download.
    Is there some special Acrobat plugin that's needed?

    Its true its not required, but the instructions for deploying the war file advise you to use enterprise manager console, which you won't have if you have just got XE or if you have installed a database without Enterprise manager.
    Ideally we need a method of deploying the war file directly
    Step 1: Installing the WAR file
    Place the fop.war file (located in apex_install_directory/utlities/fop) in an accessible location on your local machine. You then follow the directions below or can view the process by running this viewlet.
    Navigate to your OC4J Oracle Enterprise Manager Console eg: http://localhost:8888/em/
    Select the Applications Tab
    Select Deploy Button
    On the "Deploy: Select Archive" page use the option "Archive is present on local host. Upload the archive to the server where Application Server Control is running." Use the file browse to select the fop.war file and click "Next" button
    On the "Deploy: Application Attributes" page set the "Application Name" option to "fop" and clear the "Context Root " option and click "Next" Button
    On the Deploy: Deployment Settings click the "Deploy" button Message was edited by:
    Keith Jamieson

  • Error Code 1402 Could not open Key

    When I try to run the auto installer I get a message that says.:
    Error 1402.Could not open key:
    UNKNOWN\Components\2A31EAB9FA7E3C blalhblhablah
    BLALBLAHBLAH..............................
    Verify that you have sufficient access to that key, or
    contact your support personnel.
    How do I fix this?

    Hi Chardawg,
    Please try and use the below kb article for resolution.
    Error 1402 | Error 1406 | Acrobat, Reader
    Cheers,
    Kartikay Sharma

  • Getting "Could not open connection to helper tool" when restoring a disk

    I have installed OS X 10.4 on to my USB flash drive using the OS X disc that came with my iMac 24". I wanted to use the flash drive for booting the system in case I run into trouble with my iMac.
    Everything was good. I was able to use the flash drive to boot my iMac with no problem. I made an image of the flash drive using Disk Utility. However, when I tried to restore it, Disk Utility kept reporting "Restore Failure: Could not open connection to helper tool". Please tell me what to do.
    The USB flash drive is formatted using GUID Partition table.

    Same problem here.
    I successfully created an image from a drive and I'm trying to restore to another drive.
    I get the "preparing source..." for 2 seconds before the "Restore Failure" dialog with his geeky and meaningless error message. what is helper tool?! I thought I was using Disk Utility!!
    Anybody can suggest a work around for yet another problem missed by QA ?
    thanks in advance.

  • HT201412 I got i pad yesterday and i download facebook but i could not open facebook and i also can not use internet banking on ipad. what is the reason of it?

    I got ipad yesterday and i download facebook on it. But i cant login on it and i also cnt use internet banking on it. can you please tell me why?

    What happens when you try to do these things? Any error messages?
    Are you using the Facebook app or through Safari?
    Are you using your banks App, or through Safari?
    Are you able to connect to other websites successfully?

  • I get "could not open install.log file" when clicking on link in website which leads to an email address, all other links work OK.

    I am blocked by a message box headed 'Wise Uninstall' and the above error message each time I attempt to use a 'contact us' feature in a website which would normally takes me to an email address. The same happens when right-clicking on an image in any website to send to an email recipient.
    I would really appreciate your help in resolving this issue as it is most annoying as you can image.
    Many thanks, Judy.

    ok I managed to fix this! I had to run a disk repair it took a long time but after a reboot it now works fine.
    hard drive -> properties -> tools -> error-checking -> check now...

  • I could download Firefox 4, but could not open the application once putting it into the application folder. I have Mac OSX 10.3.9. Error occurs displaying "corrupt image". But won't open Firefox. Help.

    I do have and use Firefox 2, at the moment.

    Firefox 4 requires at least OS X 10.5 and an Intel Mac. The last version of Firefox that runs on OS X 10.3.9 is Firefox 2.0.0.20

  • I downloaded acrobat reader dc. after download completed, I could not open many PDF files. Error read: "could not open this file because its either not a supported file or because the file has been damaged". I opened a new user account and moved these fil

    I recently downloaded acrobat reader dc. After download was complete, I could not open PDF files. Error read "Adobe acrobat reader DC could not open this file because its either not a supported file or the file has been damaged". Any suggestions?

    HI davidd92392148,
    Is this error occurring for all PDF files that you try to open? There is an issue where all file icons can change to the PDF icon after installation, so is it possible that the files you're trying to open have been affected by this issue (and aren't actually PDF files)? Please see Application, file icons change to Acrobat/Reader icon.
    If that document isn't the key, then please tell us more about these files. Where are they stored? Did they open in previous versions of Reader?
    Best,
    Sara

  • "Could not open because it is either not supported....

    I'm trying to open a PDF from a site I frequent. When I attempt to download and open the file I get: "Could not open because it is either not supported file type or because it was damaged.
    I asked a customer service rep at the site if she was able to open the file I was attempting to open and she was able to do so.
    I can open other PDF's on my desktop. WIndows XP
    Any ideas?

    Hi,
    Can you please share the exact error message that you are receiving.
    As "~graffiti" also mentioned, it would be useful if you could let us know which version of Adobe Reader you are using and any PDF link which may not be working for you.

  • ERROR 1402   Could Not Open Key:

    Having Problems loading QUICKTIME. There was an older version but was deleted a while ago. I have used the Windows Install Clean Up. but still get 'ERROR CODE 1402 COULD NOT OPEN KEY' "HKEYLOCALMACHINE\Software\Microsoft\Windows\Current Version\Uninstall\Quicktime. Verify that you have sufficent access to that key, or contact your support personnel." I have gone to that file, and cannot do anything to that key. PLEASE HELP!!!

    ttt, same problem. please help.

  • Catalog index pdx could not open

    Hi,
    I have been trying to create a catalog (Acrobat 9 pro extended) for about 540 PDF files (and growing weekly!) and often see in my log that the index process has failed to open certain files. There is no security on these files and when I do a search it seems that they have been indexed but as it is skipping about 50-odd files each time I build/rebuild the index every week I can't be sure I have actually managed to get them all included in the index.
    What could be causing the "could not open" errors?
    Any help/ideas is appreciated.
    Thanks for your time,
    Greig

    Try posting in the Acrobat - Creation and Editing forum. You aren't using Distiller Server, and nobody comes to this forum. Good luck!

  • Error: could not open...........

    Particulars: New to Java, Windows 98, Java 1.4.0_01.
    My first program has compiled no-problem. However, when i attempt to run the program i get the following messege in the command prompt.
    Error: could not open 'C:\Program Files\Java\j2re1.4.0_01\lib\i386\jvm.cfg'
    Upon examination, my (jvm.cfg) is in a completely different directory. I don't know if i installed the Java SDK improperly, or if setting the classpath will help. I even uninstalled, then re-installed program. Also, i attempted to create a directory that matched that which is described in the error messege, (only to create a new "could not open" error).
    Could you please help? Thank you in advance, Dan......

    When you install Java it creates 3 directory trees.
    One, which starts at C:\j2sdk1.4.0_01, contains a copy of the JRE runtime (at C:\j2sdk1.4.0_01\jre\) and the additional program tools and librarys/jars that are needed to create and compile programs.
    The second, which is at C:\Program Files\Java\j2re1.4.0_01\, is a copy of the JRE runtime that was installed above.
    (The third, Webstart, is in C:\Program Files\)
    Because there are 2 JRE's, identical except for where they are, if you have one jvm.cfg you can copy it to the other location. The files are identical when installed. The 2 locations are:
    C:\j2sdk1.4.0_01\jre\lib\i386\jvm.cfg
    C:\Program Files\Java\j2re1.4.0_01\lib\i386\jvm.cfg
    Give that a try...
    That said, I've never heard of this. If you tried to install into a directory other than the default, I suggest that you use the defaults. If you used the defaults and are still having trouble, do a full removal using the Control Panel 'Add/Delete Programs' feature. Make sure that Java 2 Runtime, Java 2 SDK, and Java Webstart are removed. Then delete the 3 directory structures that match these and start over.

Maybe you are looking for

  • Material usage report

    Hi Gurus, I want the report which gives me material issued to plant maintenance order wise, plant wise & period wise report. If anybody knows any single report, then also suggest. Thanks in advance. Jayesh Narvankar SAP PP

  • How do I add currency to duration in Numbers '09

    Hi there! I'm in way over my head when it comes to using formulas (other than the quick calculations) and I could do with some of your expertise if possible? I'm a freelance graphic designer and I'm trying to produce a quoting system to calculate cos

  • IBE: Items Per Page for Display profile at Responsibility level

    Hi, we would like to have different number of items per page for different sites. We thought we would achieve it by setting profile "IBE: Items Per Page for Display" at the responsibility level and have unique responsibilities to access different sit

  • DIAdem 9.1 und DIAdem 3

    Hallo miteinander Kann ich 2 DIAdems (9.1 & 3.x) auf demselben Rechner installieren? Grund: Altes Programm läuft mit Aut nur auf altem DIAdem 3.x (Konvertieren auf VBS zu umständlich) Danke für Eure Antworten.

  • Songs I bought a year ago no longer appear available or as "Purchased" in the store. Can someone help me?

    I noticed this this morning when I activated iTunes Match on my iPhone. Songs I bought do not even display as "Purchased" in the store. The purchases are logged in my Apple ID bill history.