|
Posted by Wolfgang on 12/09/06 14:27
J.O. Aho wrote:
> Wolfgang wrote:
>> J.O. Aho wrote:
>>> Wolfgang wrote:
>>>
>>>> I still do something wrong, when I execute your Code nothing happen.
>>>> There is no need for me to show the picture (it does not appear
>>>> either),
>>>> I would be happy if I had the picture on my FTP after I called my Site.
>>> see http://www.php.net/manual/en/function.fwrite.php
>>>
>>> <?php
>>> $filename = 'test.gif';
>>> // The image isn't allowed to be larger than memory_limit in php.ini
>>> // The download time aren't allowed to be longer than timeout for server
>>> // where the script is run on.
>>> $somecontent=file_get_contents("http://www.google.de/intl/de_de/images/logo.gif");
>>>
>>>
>>> // Let's make sure the file exists and is writable first.
>>> if (is_writable($filename)) {
>>>
>>> // In our example we're opening $filename in append mode.
>>> // The file pointer is at the bottom of the file hence
>>> // that's where $somecontent will go when we fwrite() it.
>>> if (!$handle = fopen($filename, 'a')) {
>>> echo "Cannot open file ($filename)";
>>> exit;
>>> }
>>>
>>> // Write $somecontent to our opened file.
>>> if (fwrite($handle, $somecontent) === FALSE) {
>>> echo "Cannot write to file ($filename)";
>>> exit;
>>> }
>>>
>>> echo "Success, wrote to file ($filename)";
>>>
>>> fclose($handle);
>>>
>>> } else {
>>> echo "The file $filename is not writable";
>>> }
>>> ?>
>
>> I get:
>> The file 'test.gif' is not writable
>
> You (web server), don't have the right to create and write to the
> location where the PHP script is run.
>
>
>> What variable is $handle and howto point $handle to my FTP
>
> The $handler in the example is a resource handle that "keeps track of
> your stream", to change where to it has to "point", you have to change
> the $filename variable. If your ftp is another server than your
> web-server then take a look at http://www.php.net/manual/en/ref.ftp.php
>
>
> //Aho
With your advice i found:
<?php
function wwwcopy($file,$nfile)
{
$fp = fopen($file, "rb");
if($fp){
while(!feof($fp)) {
$img = $img . fread($fp, 1024);
}
}
fclose($fp);
$fp2 = @fopen($nfile,"w");
fwrite($fp2,$img);
fclose($fp2);
}
?>
<?php
wwwcopy("http://www.google.de/intl/de_de/images/logo.gif","out.gif")
?>
which does at least save a empty out.gif on the FTP Server of my provider.
Why does not my script read an image?
Thanks
.... wolfgang
Navigation:
[Reply to this message]
|