Overwriting/uploading an existing image via PHP every hour + changing directory correctly -


i need update graphic on ftp every hour. "every hour" part no problem, done via cronjob(?) i've troubles copying or uploading image in first place. maybe intinial thought how solve problem wrong? dunno...

so here code example:

<?php      $ftp_server = "servername";            $ftp_user = "user";     $ftp_pass = "password";      // set connection or die     $conn = ftp_connect($ftp_server) or die("couldn't connect $ftp_server");       // try login     if (@ftp_login($conn, $ftp_user, $ftp_pass)) {         echo "connected $ftp_user@$ftp_server\n";     } else {         echo "couldn't connect $ftp_user\n";     }      echo "current directory: ". ftp_pwd($conn) . "\n<br><br>";      $file = "example.jpg";     $newfile = "example.jpg";      if (!copy($file, $newfile)) {         echo "failed copy $file...\n";     }     ?> 

the result following:

directory: /

failed open stream: no such file or directory in /user/usernumberxyz/subdomains/demo/test/countdown/example.php on line 47

i guess have set directory right don't know how (but more because of ftp enviroment).

i think need :-/

if connect ftp via filezilla directory file want copy somewhere else this: /demo/test/countdown

for opening file in directory open this: http://subdomain.domain.com/demo/test/countdown/file.jpg

and error message shows, directory sth weird this, too(?): /user/usernumberxyz/subdomains/demo/test/countdown/example.php

so i've tried several stuff changing diectory no success:

ftp_chdir($conn, '/demo/test/countdown'); ftp_chdir($conn, 'demo/test/countdown'); ftp_chdir($conn, '/user/usernumberxyz/subdomains/demo/test/countdown/'); ftp_chdir($conn, 'user/usernumberxyz/subdomains/demo/test/countdown/'); 

evertime results in: "can't change directory".

can me , ftp_put or copy right solution?

first - use copy() copy on ftp? think it's not remote ;)

second - check permissions again, try change dir using ".." , write short test code it. example, code above try ftp_chdir() ".." , check again current directory.

third - yes, crontab every hour

ps. sorry english, hope understand , reply you.


Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -