You are here: Re: Down or Upload Problem « All PHP « IT news, forums, messages
Re: Down or Upload Problem

Posted by J.O. Aho on 12/09/06 13:53

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

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация