September 10, 200818 yr Hi people, Does anybody know why this doesn't work? $img_src = 'http://www.richardscarrott.co.uk/images/projects/thumbs/tn_cp_8.jpg'; $dest = '/project/tmp_imgs/'; $status = copy($img_src, $dest) or die("Could not copy file contents"); I get this error: Warning: copy(/project/tmp_imgs/) [function.copy]: failed to open stream: No such file or directory in /home/fhlinux145/r/richardscarrott.co.uk/user/htdocs/project/project.php on line 140 I have never used the copy(); function so may be getting the wrong end of the stick, is it actually possible to do what I am attempting? Cheers Rich.
September 10, 200818 yr I think you have to use a './' in your destination $dest = './project/tmp_imgs/';
September 10, 200818 yr Author Yeah I tried that previously, but to no avail, I've tried so many variants on the path but just can't get it to work! My file structure is like this: root/project/tmp_imgs/ root/project/project.php wonder if that affects the path I should be using? incidentally what does the ./ actually mean? I've had to use it on some require_once() paths but have no idea why!
September 11, 200818 yr Found the problem ... you have to specify the name of the file on the destination too: <?php $img_src = 'http://www.richardscarrott.co.uk/images/projects/thumbs/tn_cp_8.jpg'; $dest = './tmp_imgs/temp.jpg'; $status = copy($img_src, $dest) or die("Could not copy file contents"); ?> I just tested this and it works.
September 11, 200818 yr Author Nice one! Bit odd you have to specify a name on the destination server, seems like it should default to original name and then perhaps offer a third argument to allow a change in the name. Anyway thanks for your help!
Create an account or sign in to comment