Hi folks -
could someone please put me out of my misery, and tell me where I'm going wrong.
Simple code to execute the following unix commands:
cd /some/home/directory/tmp
wget http://www.homepage.com/images/someimg.gif
cp ./someimg.gif ../images/someimg.gif
(ok that last command is weird, but I have to mogrify it, and change it to jpgs, hence the tmp directory.)
ok the code I would have thought is below (and truncated), and through readdir() and echo's, aI know it is changing directory ok, but the wget download ALWAYS downloads to the directory where the php script was executed. How can I combine a opendir() with an exec() in one path? (to me it seems to opendir(), then reset, then exec() )
<?php
$img_url="http://www.homepage.com/images/someimg.gif";
$tmp_dir="/some/home/directory/tmp";
$get_img="/bin/wget $img_url";
opendir($tmp_dir);
exec($get_img);
$filename=basename($img_url);
$new_file=basename($img_url);
copy($filename, "../images/$new_file");
?>