PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
I am trying to copy a file from a remote server to my server. But, when I use fopen to create the file on the server, it creates a text file instead of an image file. Opening urls from fopen is turned on.
Not sure, but you might want to check to be sure that you are writing in binary mode and not text mode. I am assuming that $url contains a valid URL to an image and is not getting an error or HTML page.
arborint wrote:Not sure, but you might want to check to be sure that you are writing in binary mode and not text mode. I am assuming that $url contains a valid URL to an image and is not getting an error or HTML page.
I changed the mode for fopen to 'wb' but it had the same result. The jpeg file shows the URL instead of an image.
Edit: Figured it out. The text that appears is put there by mozilla. That means that the file does not contain any content. so file_get_contents() returns null.