php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #9806 fwrite doesn't work on Windows 2000 with Apache Server.
Submitted: 2001-03-17 06:51 UTC Modified: 2001-03-17 14:55 UTC
From: leonardo at pcnet dot ro Assigned:
Status: Closed Package: Filesystem function related
PHP Version: 4.0.4pl1 OS: Windows 2000
Private report: No CVE-ID: None
 [2001-03-17 06:51 UTC] leonardo at pcnet dot ro
I have two web servers with Windows 2000 running on them.
One of them uses as a web server Microsoft IIS and the other one Apache 1.3.19 for Windows. I have a php script which connects to a remote web server and grabs an image. The image is written on a file (with fwrite function) and saved on the local harddisk. If I run the php script on IIS the image is saved correctly. If I run the php script on Apache the image is corrupted (has a larger length in bytes; usually, between 1-50 bytes).

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-03-17 13:20 UTC] sniper@php.net
What was the fopen() line you have used?

--Jani

 [2001-03-17 13:35 UTC] leonardo at pcnet dot ro
Thank you Jani!
This is the code:

if($fd_url = fopen("http://www.some_site.com/some_picture.jpg", "r"))
{
	$fd_img = fopen("c:\\some_picture.jpg", "w");
				
	while (!feof($fd_url))
	{
		$buffer = fread($fd_url, 4096);
		fwrite($fd_img, $buffer, strlen(buffer));
	}

	fclose($fd_img);
	fclose($fd_url);
}
 [2001-03-17 14:26 UTC] sniper@php.net
RTFM: http://www.php.net/fopen

ie. Just add  the 'b':

fopen("http://www.some_site.com/some_picture.jpg", "rb"
fopen("http://www.some_site.com/some_picture.jpg", "wb"

--Jani

 [2001-03-17 14:31 UTC] sniper@php.net
Note: I just added a note into the docs for fwrite() functions about this.

--Jani

 [2001-03-17 14:55 UTC] leonardo at pcnet dot ro
Now that's ok!
Thank you. You're great.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Apr 24 12:01:29 2024 UTC