Re: [PHP] newbie: contents will not output

2003-03-11 Thread Ernest E Vogelsinger
At 04:22 11.03.2003, Anthony Ritter said:
[snip] 
I'm trying to test the following script to display the contents of the
following URL but it will not output.

Any advice will be greatly appreciated.
Thank you.
Tony Ritter
...

? $file_handler = fopen(http://www.weather.com;, r); $contents =
fread($file_handler, filesize($file)); fclose($file_handler); echo
$contents; ? 
[snip] 

You cannot stat() (i.e. use filesize()) a remote file, filesize() will
return false making your script read 0 (zero) bytes.

When reading remote files you may consider chunking them:

$fh = fopen('http://www.weather.com', 'r');
if ($fh) {
while ($chunk = fread($fh, 4096))
echo $chunk;
fclose($fh);
}

This will work perfectly (if url-fopen-wrapper is enabled in your build
anyway).


-- 
   O Ernest E. Vogelsinger
   (\)ICQ #13394035
^ http://www.vogelsinger.at/



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] newbie: contents will not output

2003-03-11 Thread Anthony Ritter
Hugh,
That script works fine.
Thank you.

What I am trying to achieve is to pull a .jpeg from a remote URL and then
resize and/or crop it after it is placed in a variable.

Your script is able to open and read the original file for output.

In the following script, I have the variable $contents holding the file -
bar.jpg - which is - say 1000x1000 - and I am trying to reduce the size of
that file to 300x300.

I have php_gd libraries installed.

Many thanks,
Tony Ritter
...

?
 $file_to_open=http://www.foo.com/bar.jpg;;
 $fp=fopen($file_to_open,r);
 $contents=fread($fp,100); //reads to eof or  ~10K whichever comes first
 $new_w=300;
 $new_h=300;
 $dst_img=ImageCreate($new_w,$new_h);
 $src_img=ImageCreateFromJpeg($contents);

ImageCopyResized($dst_img,$src_img,0,0,0,0,$new_w,$new_h,ImageSX($src_img),I
mageSY($src_img));
 ImageJpeg($dst_img);
 fclose($fp);
?


---
[This E-mail scanned for viruses by gonefishingguideservice.com]


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] newbie: contents will not output

2003-03-10 Thread Anthony Ritter
I'm trying to test the following script to display the contents of the
following URL but it will not output.

Any advice will be greatly appreciated.
Thank you.
Tony Ritter
...

html
head
/head
body
?
   $file_handler = fopen(http://www.weather.com;, r);
$contents = fread($file_handler, filesize($file));
fclose($file_handler);
echo $contents;
 ?
/body
/html






-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] newbie: contents will not output

2003-03-10 Thread Justin French
I've never opened a URL with fopen.

Have you looked for examples in the manual?  http://php.net/fopen ???

however, I can see one problem...

filesize($file) -- where is $file


Justin French


on 11/03/03 2:22 PM, Anthony Ritter ([EMAIL PROTECTED])
wrote:

 I'm trying to test the following script to display the contents of the
 following URL but it will not output.
 
 Any advice will be greatly appreciated.
 Thank you.
 Tony Ritter
 ...
 
 html
 head
 /head
 body
 ?
 $file_handler = fopen(http://www.weather.com;, r);
 $contents = fread($file_handler, filesize($file));
 fclose($file_handler);
 echo $contents;
 ?
 /body
 /html
 
 
 
 
 


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] newbie: contents will not output

2003-03-10 Thread John W. Holmes
 I'm trying to test the following script to display the contents of the
 following URL but it will not output.
 
 Any advice will be greatly appreciated.
 Thank you.
 Tony Ritter
 ...
 
 html
 head
 /head
 body
 ?
$file_handler = fopen(http://www.weather.com;, r);
 $contents = fread($file_handler, filesize($file));
 fclose($file_handler);
 echo $contents;
  ?
 /body
 /html

filesize() won't work on remote files (through http) and like Justin
said... what's $file??

---John W. Holmes...

PHP Architect - A monthly magazine for PHP Professionals. Get your copy
today. http://www.phparch.com/



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] newbie: contents will not output

2003-03-10 Thread Hugh Danaher
Anthony,

Try:

 $file_to_open=http://www.weather.com;;
 $fp=fopen($file_to_open,r);
 $contents=fread($fp,1); //reads to eof or  ~10K whichever comes first
 print $contents;

Hope this helps.
Hugh
- Original Message - 
From: Anthony Ritter [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Monday, March 10, 2003 7:22 PM
Subject: [PHP] newbie: contents will not output


 I'm trying to test the following script to display the contents of the
 following URL but it will not output.
 
 Any advice will be greatly appreciated.
 Thank you.
 Tony Ritter
 ...
 
 html
 head
 /head
 body
 ?
$file_handler = fopen(http://www.weather.com;, r);
 $contents = fread($file_handler, filesize($file));
 fclose($file_handler);
 echo $contents;
  ?
 /body
 /html
 
 
 
 
 
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] newbie: contents will not output

2003-03-10 Thread Hugh Danaher
Anthony,
Oh, I forgot to close the file, and it's an important step!

 fclose($fp);

Hugh
- Original Message - 
From: Anthony Ritter [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Monday, March 10, 2003 7:22 PM
Subject: [PHP] newbie: contents will not output


 I'm trying to test the following script to display the contents of the
 following URL but it will not output.
 
 Any advice will be greatly appreciated.
 Thank you.
 Tony Ritter
 ...
 
 html
 head
 /head
 body
 ?
$file_handler = fopen(http://www.weather.com;, r);
 $contents = fread($file_handler, filesize($file));
 fclose($file_handler);
 echo $contents;
  ?
 /body
 /html
 
 
 
 
 
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php