InMotion Hosting Support Center

php fread not working possibly

2013-08-28 8:25 pm EST

Hits: 634
I have a php script that uses php fopen and fread to copy images from a remote server. It was working yesterday. Today it suddenly doesn't work with no error reported or warnings. And I haven't changed the script code in a long time.

fopen seems to work okay. On the call to fread it seems like the script just exits without saying anything.

Another odd thing is a different php script, in a different directory also does the same function and it's still working fine it seems.

You must login before you can ask a follow up question.

You must login before you can submit an answer.



30,394 Points
2013-08-29 10:07 am EST
Hello gackstan,

Thank you for your question. We are happy to help, but is difficult to troubleshoot this issue with the limited information.

Can you provide a link to the website/script that we can look at?

Do you have permission to connect to the remote server?

Can you provide a link to the php script that is functional?

If you have any further questions, feel free to post them below.
Thank you,


You must login before you can post a comment about this answer.

Thank you John-Paul.

I did some more testing. It seems like it has something to do with this image or maybe it doesn't like the URL because I tried a different image (on and it downloaded fine.

Here is a small script that only does the remote image copy.

If it executes successfully it should be viewable at

It will also echo "z120hnjivkmrgtq0s23lv3gasq2nszazp04.jpg" if executed successfully.
32 Points
2013-08-29 2:37 pm EST
Hello gackstan,

Remove the s from the https:// part of your URL so that you aren't attempting to grab the image over encrypted SSL and it should work.

Also you might consider using some much simpler code avoiding the need for fopen and fwrite:

$url = '';
$img = 'MyNewImage.jpg';

file_put_contents($img, file_get_contents($url));

Please let us know if you continue to have any issues.

- Jacob
9,968 Points
2013-08-29 3:08 pm EST
Thank you.

The solution Jacob provided worked. But I checked a log of images I've downloaded successfully in the past (weeks, months ago) and they were over https. I think you guys have changed something on the servers that prevents connections over https in php because I ran into a new problem that involves https in php too (which I'll post in another post).
32 Points
2013-08-29 6:09 pm EST
Hello gackstan,

Looking further at the issue, it looked like when your PHP script was executing it was having issues loading up the SSL library. That was causing it to fail when trying to pull content in over a SSL connection.

We have re-deployed all of our PHP libraries out to the server, and this seems to have resolved the issues now. Sorry for the problems, and please let us know if you see these issues persist.

- Jacob
9,968 Points
2013-08-30 1:08 pm EST
Like this Question?

Support Center Login

Our Login page has moved, Click the button below to be taken to the login page.

Social Media Login

Social Login Joomla

Need more Help?


Ask the Community!

Get help with your questions from our community of like-minded hosting users and InMotion Hosting Staff.

Current Customers

Chat: Click to Chat Now E-mail:
Call: 888-321-HOST (4678) Ticket: Submit a Support Ticket

Not a Customer?

Get web hosting from a company that is here to help. Sign up today!