I have looked all over the Internet and all over Stack Overflow and I am unable to find a solution to my problem.
I basically have a PDF file which I am able to access through a web address if I hit in a web browser.
Without away, it is: http://url.com/manage/pdf/file.pdf?id=172). I know it seems unusual, but trust me, hitting this address gives my a PDF file.
But if I try an hit it using file_get_contents, I get an error:
failed to open stream: Connection timed out (obviously I have cut out file names and line numbers).
I am not looking to to suppress the error (I already can do this), nor am I looking it for a way to handle the error. I want to know WHY the error is happening so I can stop it from happening.
Particularly as this same line of code has no issues with getting other files in a similar manner.
Because of constraints beyond my control, I can not use cURL.
The file is less than 1MB and all the relevant settings in php.ini have been checked (can’t remember them off the top of my head, but allow open socket, and socket time outs).
Can anyone give me an answer that I have not seen already that will actually work! Let me know if you need more details.
Thank you in advanced!
You can’t put a file to a remote server. If you are trying to open the PDF from that site you need to use
file_get_contents().http://url.com/manage/pdf/file.pdf?id=172
Your link includes the word ‘manage.’ If you need to be logged in to see that file then yes your browser would see it but PHP cannot because it isn’t logged into the server. The second issue is if I view that link I am redirected to http://www.coolchaser.com/?id=172. If you are dealing with a link that may have a redirect you should switch to CURL and in the curl options you tell it to redirect and the number of levels of redirection that are allowed.